0

I'm looking through a plugin that somebody else has written and for some reason all my click event handlers are destroyed. I'm going through the code and there are several uses of unbind which I've commented out to determine whether it is causing the issue. Unfortunately that is not enough, so I'm wondering if there are other ways to remove/destroy event handlers?

Thanks!

Steven Cheng
  • 1,041
  • 3
  • 14
  • 25
  • 1
    You may want to read through http://stackoverflow.com/questions/209029/best-way-to-remove-an-event-handler-in-jquery – Justin Ethier Jul 08 '10 at 15:04
  • Thanks for the link... maybe I'm missing something, but doesn't the above refer to the use to unbind? I've commented out all instances of unbind and still no luck. – Steven Cheng Jul 08 '10 at 15:11
  • is there a stopPropagation(); (or return false;) that is preventing it from getting to your handlers? – Matt Evanoff Jul 08 '10 at 15:27
  • unfortunately no stopPropagtion... some uses of return false but they don't appear to be interfering. – Steven Cheng Jul 08 '10 at 15:58

1 Answers1

0

There is .unbind() which will unbind a collection's event once, or .die() which is the opposite of .live(), meaning it will unbind the collection's event that is currently set, and any events that are attached in the future.

Michal
  • 1,005
  • 6
  • 10
  • Are you doing any DOM manipulation for the elements with .click() events? If you use .remove(), then event handlers aren't saved. If you use .detach(), then you need to make sure you are caching the removed elements. – Michal Jul 08 '10 at 16:03
  • I'm not doing any direct DOM manipulation in my own code, however when I execute $($.plugin).remove() that is when my click events are being removed. – Steven Cheng Jul 08 '10 at 16:14