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?