has anyone experienced something like this. I have my callback functions and implement them like this.
function onBodyLoad()
{
$('.loading').bind('click',function(){
console.log("loading screen should show now");
$('#teaserslider').hide();
$('#resultslider').hide();
$('#loading-screen').show();
})
document.addEventListener("deviceready", onDeviceReady(), false);
}
function onDeviceReady()
{
$('#loading-screen').hide();
setUpDatabase();
document.addEventListener("online", deviceIsOnline, false);
}
function deviceIsOnline(){
alert("Im online!");
if (true){
persistResultHistory();
}
}
Connected to Wi-Fi, I get the (“Im online!”) pop up 3 times. I searched my whole project, it only gets invoked here. So why 3 times? Also, when I switch on the airplane-mode without any connection to the internet, I get the pop-up 1 time. Anyone has experienced similar behavior?
Any help greatly appreciated.
You are calling the method immediately instead of giving reference of the method, so replace:
With
Also put the
addEventListener()outside of theonBodyLoad()function and make it run immediately.Full source code here – https://gist.github.com/3077171