jQuery Mobile的 - changePage不pageinit

问题描述:

在这里工作是示例代码(test.html中),jQuery Mobile的 - changePage不pageinit

<!DOCTYPE html> 
<html> 
<head> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css"/> 
<script src="http://code.jquery.com/jquery-1.8.3.js"></script> 
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> 
</head> 
<body> 

<div data-role="page" id="page1"> 
<div data-role="content" id="content">Page 1</div> 
</div> 

<div data-role="page" id="page2"> 
<div data-role="content" id="content" >Page 2</div> 
</div> 

<script> 
$('#page2').live('pageinit',function(evt) { 
    $.mobile.changePage($('#page1'),{allowSamePageTransition:true}) 
}); 
</script> 

</body> 
</html> 

当我尝试访问./test.html#page2同时使用Firefox和Chrome,它是预计将更改为page1。但它并未总是成功更改为page1。有时候,它在页面2中仍然保持不变。任何人知道为什么?

谢谢!

为什么不试试如下

$('#page2').on('pageshow',function(evt) { 
    $.mobile.changePage($('test.html#page1'),{allowSamePageTransition:true}) 
}); 

和另一个忠告凭我的经验是,在导航错误的缓行嵌套JQM页面的结果。作为一个拇指规则,我总是为我的JQM HTML页面分开页面。