Widget : callback or event handler ?
Hi,
I've been studying how to create widgets with jQuery UI, and I'm now wondering what the difference between callbacks and event handlers is.
In the widget definition, I can write this line to trigger a 'change' event.
- this._trigger('change', 0, data);
And to catch this event, I can write one of those lines :
- $('.target').mywidget({
- change: function(event, data) { alert(data); } // callback to handle change event
- });
or
- $('.target').bind('mywidgetchange', function(evt, data) { alert(data); });
// event handler for change event
Am I right ? It actually seems quite similar... or am I missing something ?
When should I use callbacks ? And when should I use event handlers ?
Thank you in advance.
Clément