I'm using JQuery on
method to attach an event handler to the window object:
$(window).on('resize', function(e){
/** my functional code goes here **/
e.stopPropagation();
});
This is event handler is being called multiple times: The reason this is so is because the event handler is in the initialization section of a JQuery plugin, so when someone calls the plugin constructor like so:
$('selector').myPlugin({settings_1});
$('selector').myPlugin({settings_2});
$('selector').myPlugin({settings_3});
The event handler gets attached 3 times.
I'm looking for a way to identify and decommission all but one of the 3 event handlers (using off
method) so that during a resize, only one of them will get triggered.
How do I identify the event handlers and remove the ones I want?