Javascript 检测jquery mobile上的changepage
使用Javascript 检测jquery mobile上的changepage,javascript,jquery,jquery-mobile,Javascript,Jquery,Jquery Mobile,使用.changePage()函数更改页面时,如何执行代码 例如,我使用以下代码: $.mobile.changePage( "index.html#pageTwo" ); 当第二页加载时,我想这样做: alert("Test"); 在你的。。这样说: // Jquery loaded here <script> $(document).on("pageshow","#pageTwo", function() { alert("Test"); } &l
.changePage()
函数更改页面时,如何执行代码
例如,我使用以下代码:
$.mobile.changePage( "index.html#pageTwo" );
当第二页加载时,我想这样做:
alert("Test");
在你的。。这样说:
// Jquery loaded here
<script>
$(document).on("pageshow","#pageTwo", function() {
alert("Test");
}
</script>
// jquery mobile loaded here
//Jquery在这里加载
$(文档)。在(“pageshow”、“#pageTwo”,函数()上{
警报(“测试”);
}
//jquerymobile在这里加载
注:
有很多事件,您使用的是哪个版本?我使用的是版本1.4.2检查这个jqmtricks.wordpress.com/2014/03/26/jquery-mobile-page-events/可能重复的
mobileinit
应该只放在JQM之前。其余的应该在JQM之后加载。请注意,pageshow
以及页面事件从1.4开始都是不推荐的。)@奥马尔说得很好。这是我在JQM 1.3.1中使用的结构,它可以正常工作。
<html>
<head>
<script src="path/to/jquery.js"> // load jquery
<script src="path/to/common.js"> // all jquery mobile page event bindings are placed in here
<script src="path/to/jquery_mobile.js"> // load jquery mobile
</head>
<body>
<div data-role="page" id="pageOne"> This is page one content </div>
<div data-role="page" id="pageTwo"> This is page two content </div>
</body>
</html>