madrobby/zepto — Issue #358: Disabling All Events?
Author: tekmonk
Created: 2011-12-13 00:11:51+00:00
State: open

What I'm trying to do is replicate a bit of jQuery Mobile with page transitions.

A problem arises if I've switching between two divs on the same page...

Page 1 has links to other areas of the page (via hash tags) and Page 2 has a form on it. This is a simple switch, basically - page1.removeClass('page-active'); page2.addClass('page-active');

If i "tap" on my screen from Page 1 to get to Page 2 (and I'm tapping in the general area of a form element- like a SELECT), it will bring focus to that element. Which means, if i'm accidentally tapping a Select, it will bring up that Select dialog.... I want the page shown first without interference from the click / tap, then the user can click whatever.

I did come up with a little loading function that binds and unbinds all $("a")... which did the trick when it comes to links, but then I realized the SELECT and RADIO buttons aren't affected by that, so the issue still happens.

Anyway....

What would be the best way to, if at all possible, to unbind everything during a page loading transition?

I attach event listeners all thorough my code ( some change button colors, one module handles what to do with a link click, etc).. so a blanket $(window).unbind('tap click doubletap') are probably not going to work. Also I'm not trying to lose all of the .binding done at the end of the zepto.js that handles all of the touch and tap events.

Perhaps I'll just unbind("tap click") from all SELECT / INPUT elements, then rebind them after the load.

Unless of course someone has an easier solution.