我为"pagebeforechange"(非常类似于jQuery Mobile Documentation自己的代码)设置了以下监听器,并在主页上调用了http:// localhost /#product?id = 255979
//Bind Listener for Product Details
$(document).bind( "pagebeforechange", function( e, data ) {
//Only Run If Site is Initialized
if( ajaxSite.options.initialized ) {
if ( typeof data.toPage === "string" ) {
var u = $.mobile.path.parseUrl( data.toPage ),
pl = /^#product/;
if ( u.hash.search(pl) !== -1 ) {
console.log("showProduct being called.");
ajaxSite.showProduct( u, data.options );
e.preventDefault();
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
当我打开JavaScript控制台并单击链接时,我看到以下内容:
showProduct being called.
showProduct being called.
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到任何关于为什么它会被调用两次的事情.我看到其他错误,其中vclicks由于边缘单击而被注册两次,但这没有任何意义,因为它依赖于实际的页面更改.