In phonegap do I need the $(document).ready(...) inside the deviceready event function? Can I be sure that document is loaded when the deviceready event is called?
Example:
document.addEventListener('deviceready',
function() {
$(document).ready(function() { // is this too much?
initCampusWeb();
});
}, false);
The way that this works is jQuery(document).ready() fires first and then deviceready fires.
I generally set up my code like this:
jQuery(document).ready(function () {
// do document ready stuff
}).on('deviceready', function () {
// do deviceready stuff, put all calls to plugins in here
});
So the question as to where initCampusWeb goes depends on what you are doing inside that function. If it uses plugins, put it inside the deviceready handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With