Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery Mobile:根据条件防止更改页面_Jquery_Jquery Mobile - Fatal编程技术网

JQuery Mobile:根据条件防止更改页面

JQuery Mobile:根据条件防止更改页面,jquery,jquery-mobile,Jquery,Jquery Mobile,我希望防止基于条件(计算或服务调用的结果)的页面更改 我已经阅读了以下链接,但在iOS设备(混合应用程序)上没有任何东西适合我 我的HTML看起来像: <ul data-role="listview" data-inset="true"> <li><a href="#secondPage" Onclick='change(0)' id='secBtn'>Second Page</a></li> &l

我希望防止基于条件(计算或服务调用的结果)的页面更改

我已经阅读了以下链接,但在iOS设备(混合应用程序)上没有任何东西适合我

我的HTML看起来像:

<ul data-role="listview" data-inset="true"> 
        <li><a href="#secondPage" Onclick='change(0)' id='secBtn'>Second Page</a></li>
        <li><a href="#thirdPage" Onclick='change(1)' id='thrBtn'>Third Page</a></li> 
</ul>
现在,当调用e.preventDefault()时,它会停止所有按钮、链接等上的所有事件

我只想在特定按钮、LI或项目上停止/运行。我不知道如何做到这一点

有什么建议吗

function change(val) {
if(val == 1) {
    $.mobile.changePage("#thirdPage", { transition: "slide"});
}else {
    $(document).bind("pagebeforechange", function(e ,ob) {
if(ob.toPage && (typeof ob.toPage==="string") && ob.toPage.indexOf('page.html') >=   0) {
    e.preventDefault();
    e.stopPropagation();             
    $.mobile.activePage.find('.ui-btn-active').removeClass('ui-btn-active');
      }
    });
 }

}