0

Using Ripple in Chrome I'd expect my on and off line events to be called as I switch the network from a connected state (WiFi, 4g, etc) to and from None. But this doesn't happen. At best offline is called if I start the emulator offline.

Deploying to a phone (Android) the events seem to be called if I go into Airplane mode then back to online.

Here is my code:

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);
}
};

Is this a bug in Ripple or something I'm doing wrong?

Aardvark
  • 8,474
  • 7
  • 46
  • 64

1 Answers1

1

You are correct, this was a bug in Ripple. It has been fixed in the latest version of Ripple:

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

Suggest updating to 0.9.11 and testing your code again.

Adam Stanley
  • 1,875
  • 1
  • 15
  • 16
  • Adam, are you 100% sure? I have `Ripple Emulator (Beta) 0.9.15` installed as Chrome Extension on Windows 7 and [I can clearly see, that Ripple Emulator is **not** firing any events](http://stackoverflow.com/questions/17701869/ripple-emulator-doesnt-fire-events). Everything works just fine on final, real device, so JS code (event handlers) seems to be fine. – trejder Jul 22 '13 at 06:31
  • I'm using version 0.9.15 as chrome extention on windows 8.1 and have same problem... any fixes? – kasper Taeymans Dec 02 '13 at 00:09