Recommended way to remove events on destroy with jQuery UI Widget Factory
Posted
by
user1031947
on Stack Overflow
See other posts from Stack Overflow
or by user1031947
Published on 2012-12-17T01:49:43Z
Indexed on
2012/12/17
23:03 UTC
Read the original article
Hit count: 300
I'm using the jQuery UI Widget Factory to build a jQuery plugin.
My plugin binds custom events to the window...
_subscribe: function() {
$(window).on("dragger.started", function() { ... });
}
I am wondering how to go about removing these events, when a particular instance of the plugin is destroyed. If I use...
destroy: function() {
$(window).off("dragger.started");
}
...then that will mess up any other instances of the plugin on the page, as it will remove all "dragger.started" events.
What is the recommended way to go about destroying only those events that are associated with an instance of the plugin?
Thanks (in advance) for your help.
© Stack Overflow or respective owner