Here is my code which suppose to handle device and network events for my phonegap application
define(['jquery', 'knockout'], function ($, ko) {
var deviceHandler = {
Online: null,
Offline: null,
OnNavigateBack: null
};
function HandleBackClick() {
return deviceHandler.OnNavigateBack;
}
function HandleOnlineState() {
return deviceHandler.Online;
}
function HandleOfflineState() {
return deviceHandler.Offline;
}
document.addEventListener('online', HandleOnlineState, false);
document.addEventListener('offline', HandleOfflineState, false);
document.addEventListener('backbutton', HandleBackClick, false);
return deviceHandler;
});
When I import this module I assign my own function to devicecs online event in this way
MobileDevice.Online = function() {
alert("we have updated information..");
};
but it never gets called. can anyone help me with this module? one more thing to not: this assignment is differently called after device ready event.