javascript - iOS Touch event passes through on DOM insertion -


in mobile safari on ipad , in ios uiwebview seeing following behavior.

i have page replaces contents of dom element using javascript. first page has button when pressed remove elements container element , new set of html inserted container.

the problem when button pressed , html switched out touch event passes through newly inserted html page. in case have text input on 2nd page in same position button on 1st page. so, when button pressed touch event passes through , puts focus on text input , soft keyboard comes up.

do have details on why happens or how can prevent or workarounds problem?

view link below on ipad , see talking about. doesn't seem happen on "click" event, both "touchstart" , "touchstop" makes happen.

http://jsfiddle.net/tcollins/btmyd/embedded/result/

html

<h3>touch start</h3> <div id="container2">   <button id="thebutton2">press me</button> </div> 

javascript

$('#thebutton2').bind('touchstart', function(){    var html = '<input type="text">';    $('#container2').empty().append(html); }); 

have tried adding evt.preventdefault(); , evt.stoppropagation(); before append? so:

      $('#thebutton2').bind('touchstart', function(evt){        evt.preventdefault();        evt.stoppropagation();        var html = '';        $('#container2').empty().append(html);     });  

sadly, don't have iphone connot test it, should stop event propagating.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -