0

Chrome で Ripple を使用すると、ネットワークを接続状態 (WiFi、4g など) から None に切り替えるときに、オンライン イベントとオフライン イベントが呼び出されることを期待します。しかし、これは起こりません。エミュレータをオフラインで起動すると、せいぜいオフラインが呼び出されます。

電話 (Android) に展開すると、機内モードになってからオンラインに戻ると、イベントが呼び出されるようです。

これが私のコードです:

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 のバグですか、それとも私が間違っているのでしょうか?

4

1 に答える 1

1

そうです、これは Ripple のバグでした。Ripple の最新バージョンでは修正されています。

https://github.com/blackberry/Ripple-UI/issues/663

0.9.11 に更新してコードを再度テストすることをお勧めします。

于 2013-01-14T15:02:25.480 に答える