javascript - 棘轮 push.js 与 phonegap (cordova)

标签 javascript html cordova ratchet-bootstrap push.js

我使用棘轮。我的 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.

来自docs site

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/

相关文章:

javascript - 尝试在我的 React 项目中设置状态时无法读取未定义的属性 setState

Javascript 禁用按钮

javascript - 如何在innerHTML中添加调用电话号码链接

css - CSS绘图和Zepto/Phonegap有问题吗?

javascript - Cordova 媒体插件,如何测试浏览器播放的声音?我总是得到 ReferenceError : Media is not defined

javascript - 在javascript中压缩一个blob

javascript - 如何将 Three.js 转换为 .STL 文件以进行 3D 打印?

javascript - 在 Rails 4 App 上通过相对路径调用 Slider Revolution 资源

html - 无法从首页删除标题?

javascript - Cordova 联系人插件 ContactFindOptions