Jquery mobile 什么';在jQuery Mobile中为不同页面附加按钮单击事件的适当方式是什么?

Jquery mobile 什么';在jQuery Mobile中为不同页面附加按钮单击事件的适当方式是什么?,jquery-mobile,Jquery Mobile,我试过了,但很明显,我还是会被鬼点击 例如,我在page1.html中使用以下代码: <script type="text/javascript"> $(document).on('pageinit', '.ui-page',function(){ $("#someButtonForPage1").click(function(){ $.mobile.changePage("page2.html"); }); }

我试过了,但很明显,我还是会被鬼点击

例如,我在page1.html中使用以下代码:

<script type="text/javascript">
    $(document).on('pageinit', '.ui-page',function(){
        $("#someButtonForPage1").click(function(){
            $.mobile.changePage("page2.html");
        });
    });
</script>

$(document).on('pageinit','.ui-page',function()){
$(“#somebuttonforpage 1”)。单击(函数(){
$.mobile.changePage(“page2.html”);
});
});
在第2页,我有以下内容:

<script type="text/javascript">
    $(document).on('pageinit', '.ui-page',function(){
        $("#someButtonForPage2").click(function(){
            $.mobile.changePage("page1.html");
        });
    });
</script>

$(document).on('pageinit','.ui-page',function()){
$(“#someButtonForPage2”)。单击(函数(){
$.mobile.changePage(“page1.html”);
});
});
至于页面,它们只包含一个页眉、一个内容体(其中包含button元素)和一个页脚。所发生的事情是,点击按钮将使页面相互转换至少几次。也就是说我还是会被鬼点击


什么能绝对解决这个问题?

这是jQuery移动版的一个常见问题。在绑定任何事件之前,需要检查该事件是否已绑定到该元素。例如,按钮上有2个单击/点击事件,将执行想要的操作2次

你会找到我对同一个问题的答案


我的第一个示例使用事件过滤器,您可以找到它,示例是。

您看过多页布局了吗?