jqueryMobile tap and bubbling/propagation

若如初见. 提交于 2019-12-06 08:01:08

问题


See this sample in android 2.x browser..its a sample to replicate a scenario in my application..

http://johnchacko.net/samples/tap.html

Its about listening to 'tap' and calling changePage from listener...

The second page is having some input fields, 'tap' event is bubbling/propagating to second page and focus is randomly set to input fields...

I read similar issues and want to know anybody experienced same issue and got a workaround for it....

Or I must use only 'click' ?


回答1:


It can be fixed in few ways:

  1. On tap/click event use this methods before you call changePage:

    e.stopPropagation();
    e.stopImmediatePropagation();
    

    or:

    $(document).on('tap', '#button', function(){       
        e.stopPropagation();
        e.stopImmediatePropagation();
        // Rest of the code
    });
    
  2. Initialy disable all input boxes on a second page, on a pageshow event use settimeout function and enable them after cca 10 ms



来源:https://stackoverflow.com/questions/14624621/jquerymobile-tap-and-bubbling-propagation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!