2012-09-01 139 views
0

我正在使用多视图插件jquery mobile中的更改页面事件时页面更改函数调用两次意味着如果我使用警报它显示相同的警报两次,当我点击后退按钮一些它显示页面,但当我经常这样做时,它显示插件中的错误可以帮助我的任何一个插件文件jquery移动函数调用两次

回答

0

你的意思是pagebeforechange事件? 此事件按设计触发两次。 这两个调用之间的区别是数据的toPage属性:

jQuery(document).bind('pagebeforechange', function(e, data) { 
    var toPage = data.toPage; 
    if(typeof toPage === 'string') { 
     // -- triggered first 
     // -- toPage is a string containing the page`s url 
    } else { 
     // -- triggered second 
     // -- toPage is an jQuery collection object containing the page 
    } 
});