I\'m trying to do a simple alert(\'test\') app, but the event isn\'t being fired, this is the code:
function onLoad() {
document.addEventListener("de
I would rather take an asynchronous approach, like so:
bindEvents: function () {
var me = this;
document.addEventListener('deviceready', function () {
me.onDeviceReady();
}, false);
$(document).ready(function () {
me.onDocumentReady();
});
},
documentReady: false,
onDocumentReady: function () {
this.documentReady = true;
this.checkReady();
},
deviceReady: false,
onDeviceReady: function () {
this.deviceReady = true;
this.checkReady();
},
checkReady: function (id) {
if (this.documentReady && this.deviceReady) this.load();
},
load: function () {
// do stuff
}
This way you don't risk attaching handlers after the event has occurred.