我使用棘轮。我的 phonegap 应用程序有两个页面,包含 jquery.js、ratchet.js 和 blockui.js(基于 jQuery)。
index.html:
<script>$.blockUi()</script>
<a href="2.html" data-transition="slide-in">2.html</a>
2.html:
<a href="index.html" data-transition="slide-out">index.html</a>
起初 $.blockUi()
运行正确。然后我按第一页的链接。在我按下第二页上的链接后,没有 JavaScript 运行。我该怎么办?
最佳答案
来自docs在 Github 上:
Script tags containing JavaScript will not be executed on pages that are loaded with push.js. If you would like to attach event handlers to elements on other pages, document-level event delegation is a common solution.
Push.js binds an event to the document that returns a detail object and can be used to fire a callback.
因此我相信您必须使用此事件监听器来运行您的脚本:
window.addEventListener('push', myFunction);
关于javascript - 棘轮 push.js 与 phonegap (cordova),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22257041/