我可以在Cordova 2.5上多次听到deviceready吗? [英] Can I listen for deviceready multiple time on Cordova 2.5?
本文介绍了我可以在Cordova 2.5上多次听到deviceready吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以为每个html网页注册deviceready事件吗?我使用Cordova 2.5的初始化代码,它工作正常。当我把这些代码复制到一个新的html文件,它总是调用index.html的initialize()函数。
Could I register 'deviceready' event for each html page? I use the initialize codes of Cordova 2.5 and it work fine. When I copy these codes to a new html file, It always call to the initialize() function of the index.html.
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicity call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
console.log('Received Event: XXX ' + id);
}
};
===============
HTML档案:
=============== HTML file:
....
<script type="text/javascript">
app.initialize();
</script>
....
推荐答案
设备就绪只会触发一次。它将下一次火灾时,只有当应用程序被杀死,并再次打开。
Device ready will fire only once. It will fire next time only when the app is killed and opened again.
这篇关于我可以在Cordova 2.5上多次听到deviceready吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文