Search code examples
jqueryipadsafariios5mobile-safari

touchstart preventDefault in body = can't focus input


I'm developing a page to be shown in an iPad and added this jquery code to prevent user from zooming the page:

$("body").bind("touchstart", function(e) {
    e.preventDefault();
})

And I have an input text in my page that, when i've added code above, it can't be focused using touch, in other words, keyboard doesn't appear when user touches the input.

It used to work in Safari IOS 4.2 but with Safari IOS 5 it doesn't work any more.

Any idea on how to make my input works without letting the user zoom the page?


Solution

  • I resolved this problem with a plugin that detects doubletap event (see here for a description), then I use preventDefault on doubletap and my input can normally treat touchstart.