Skip to content
Advertisement

Trying to unbind events on iPad2 with javascript

Bit of background, we are creating an html5 ‘app’ for the iPad, which has everything contained in a single page, and all the content is dynamic.

I have a dynamically generated anchor, which then has a click event bound to it as so:

 $j(toElement).find(".moveSlideUp").bind('click', addSlideToPresentation_click);

This all works fine, however the problem is that once we navigate away from that page/section, and navigate back to it, the event handler is bound a second time, and thus fires twice (or 3 or 4 times etc…).

I have tried calling unbind before binding, but this makes no difference – any ideas?

Advertisement

Answer

You can bind handler in the same context which when is reloaded releases your handler as well. Or check if handler is already bound:

jquery check if event exists on element

test if event handler is bound to an element in jquery

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement