Cordova Ripple下的my PhoneGap应用程序中未正确触发联机和脱机事件
使用Chrome中的Ripple,当我将网络从连接状态(WiFi、4g等)切换到无状态或从无状态切换到无状态时,我希望能够调用我的在线和离线事件。但这并没有发生。如果我离线启动仿真器,则最多调用offline 将事件部署到手机(Android)上,如果我进入飞行模式,然后返回在线状态,事件似乎会被调用 这是我的密码:Cordova Ripple下的my PhoneGap应用程序中未正确触发联机和脱机事件,cordova,ripple,Cordova,Ripple,使用Chrome中的Ripple,当我将网络从连接状态(WiFi、4g等)切换到无状态或从无状态切换到无状态时,我希望能够调用我的在线和离线事件。但这并没有发生。如果我离线启动仿真器,则最多调用offline 将事件部署到手机(Android)上,如果我进入飞行模式,然后返回在线状态,事件似乎会被调用 这是我的密码: var app = { // Application Constructor initialize: function() { this.bindEvents(); },
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);
},
onOffline: function () {
var parentElement = document.getElementById("devicestatus");
var offlineElement = parentElement.querySelector('.offline');
var onlineElement = parentElement.querySelector('.online');
onlineElement.setAttribute('style', 'display:none;');
offlineElement.setAttribute('style', 'display:block;');
},
onOnline: function () {
var parentElement = document.getElementById("devicestatus");
var offlineElement = parentElement.querySelector('.offline');
var onlineElement = parentElement.querySelector('.online');
offlineElement.setAttribute('style', 'display:none;');
onlineElement.setAttribute('style', 'display:block;');
},
onDeviceReady: function() {
var parentElement = document.getElementById("devicestatus");
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
document.addEventListener('offline', app.onOffline, false);
document.addEventListener('online', app.onOnline, false);
}
};
这是Ripple中的错误还是我做错了什么?你是对的,这是Ripple中的错误。它已在Ripple的最新版本中修复:
建议更新到0.9.11并再次测试代码。Adam,你100%确定吗?我已经在Windows7和Windows上安装了
Ripple Emulator(Beta版)0.9.15
作为Chrome扩展。在最终的真实设备上,一切都很好,所以JS代码(事件处理程序)似乎很好。我在windows 8.1上使用0.9.15版作为chrome扩展,但有同样的问题。。。有办法吗?