We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27519
    • 275 Posts
    In apps like modExtra I see that sometimes listeners are registered, like so:
            MODx.msg.confirm({
                title: _('modextra.item_remove')
                ,text: _('modextra.item_remove_confirm')
                ,url: this.config.url
                ,params: {
                    action: 'mgr/item/remove'
                    ,id: this.menu.record.id
                }
                ,listeners: {
                    'success': {fn:function(r) { this.refresh(); },scope:this}
                }
            });
    


    In the PHP action the following is used to fire the event:

    return $modx->error->success('',$item);
    


    Is it possible to have other listeners, or even user defined listeners, like (for example due to business constraints the item cannot be removed from the database):
                ,listeners: {
                    'cannot_delete': {fn:function(r) { this.myHandler(); },scope:this}
                }
     


    Would that require a different approach from the PHP side?
      MODx Revolution / MAMP / OS X
      • 28215
      • 4,149 Posts
      splittingred Reply #2, 16 years ago
      Not unless you build them; currently the only listeners are ExtJS ones, with the exception that MODx.panel.* extended items have a ’success’ and ’failure’ event that fires on success or failure of a form.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com