【发布时间】:2013-08-12 21:55:55
【问题描述】:
我有以下使用 JQuery Mobile 的代码。这里的重点是我希望在触发 'pageshow' 事件时执行一些代码。
以下所有代码都可以在 Chrome 上正常运行。我可以看到控制台日志。但是,当我将其作为 Phonegap 应用程序的一部分运行时,我从未触发过“pageshow”事件。
已经对此进行了一段时间的调查,但没有成功。希望有人可以向我解释为什么我的事件丢失以及需要哪些步骤才能使此代码在 Phonegap 上运行。
details.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"> </script>
<link rel="stylesheet" href="css/index.css" />
<!-- cordova -->
<script src="cordova-2.2.0.js"></script>
</head>
<body>
<div data-role="page" id="details_page">
<a href="places.html" data-transition="slide" data-direction="reverse">Back</a>
<h3>Hi I am second page</h3>
</div>
<script src="js/details.js"></script>
</body>
</html>
details.js
$("#details_page").live("pageshow", function() {
console.log('I am alive! (details.html)');
});
【问题讨论】:
-
我试过了,事件被触发了..你确定你没有遗漏什么吗?
标签: cordova jquery-mobile