Monday, June 21, 2010

JQuery droppable "unspecified error" in IE

I was implementing some Drag'N'Drop algoritms using JQuery .draggable & .droppable plugins, when in IE got "unspecified error". Thanks to Microsoft, they finaly got released so called "Development Tools". Debugging my page using that, gave me exception inside jQuery's code. It was the line saying "d=b.getboundingclientrect()".

It got me a while to understand why that happens, and the answer is:
jQuery's event handles/listerners are not unbinded automatically from the elements you remove from the DOM... they keep firing. So every time you use something like $('...').droppable(...
you should also do $('...').droppable('destroy'), if you remove that $('...') from the DOM. I did.

Conclusion: $('...').droppable('destroy');


2 comments:

  1. Thanks, this blog post helped me to fix the same issue!

    ReplyDelete
  2. Beautiful!!! Many thanks!!! This was looking like a 4-8 hour troubleshooting task when I found your post, and you set me straight in < 20 minutes. Have a beer on me and send me the tab. Better yet, have two!

    ReplyDelete