【发布时间】:2013-04-18 12:24:46
【问题描述】:
我正在使用 jQuery Mobile,我想在用户单击主页上的按钮后将浏览器重定向到另一个页面。 为此,我写道:
$.mobile.changePage("album-search-results.html",{
data:{area:searchArea, value:searchValue},
transition: "pop"
});
它运行良好,它加载了正确的页面,甚至在 URL 上放置了正确的值。不幸的是,没有触发 pageshow 事件:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
</head>
<body>
<div data-role = "page" data-theme = "d" id = "SearchResults">
<div data-role = "header">
<h1>Aggregator</h1>
</div>
<div data-role = "content">
</div>
</div>
<script type="text/javascript">
$("#SearchResults").on("pageshow",function(event, ui){
console.log(ui.prevPage);
});
</script>
</body>
</html>
当我从上一个页面加载此页面时,控制台始终为空。怎么了? 谢谢
【问题讨论】:
-
我以为 pageshow 只是目标文档的一个事件? developer.mozilla.org/en-US/docs/Web/Events/pageshow
标签: javascript html jquery-mobile jquery