I have developed a jquery ui-plugin and can't really understand which of these methods to use. According to the jquery ui documentation I should use _trigger to trigger the events, this allows the handlers to be initialized with the plugin like
$("#id").pluginname({
click: function(){
//called when clicked
}
});
But if I later want to attach more listeners to this event I can't find any way to do that. I'm trying to use jquery bind, but that does not work. example:
$("#id").bind("click", function(){
//This does not get fired on click if using _trigger
})
The only solution I have so far is to fire of both, but it feels kind of strange. My code must do the following to work:
$("#id").pluginname({
click: function(){
//called when my plugin uses this._trigger('click')
}
}).bind(function(){
//called when my plugin uses this.element.trigger('click')
});
I'm using custom events, but didn't think that was relevant for asking this question. Anyone have an idea on how to use event chaining when using _trigger()?