Widgets internal events - separate treatment of handlers and callbacks.
I have a task of creating composite user controls - like an autocomplete bound together with two buttons (namely, "Update" and "Create"), which is bound to a bunch of service methods responsible for selecting, editing and creating entities. It is used for on-the-fly entities management.
The problem is - to provide a consistent behaviour I have to use internals of the associated widgets, like triggering internal events (e.g. if we create a new entity, we should select it immediately in autocomplete, and have to trigger the 'autocompleteselect' event for a newly created item).
This leads to an issue - on manual trigger of widget's event the explicitly bound handlers will fire, but not the callbacks, which have been provided as options
to put it simpler:
- $('#elem').autocomplete({select : function(){ alert('foo'!);}}).trigger('autocompleteselect', {});
won't do anything, whereas
- $('#elem').autocomplete().bind('autocompleteselect', function(){ alert('foo'!);}}).trigger('autocompleteselect', {});
This design is actually pretty sophisticated, but I still think - even though callbacks in options are there for convenience, they should be called together with the actual event handlers, no matter where and how they are called.
The question - do you think this is a mistake and should it be fixed in future UI releases?