I've been through the solutions in the two questions related to this - JQuery document.ready vs Phonegap deviceready and Correct way of using JQuery-Mobile/Phonegap together? and am still no closer to a solution.
Our issue is with PhoneGap Build plugins. We're using the Device plugin to target specific UI component positions and sizes to iPhones 4 and 5. In doing so we need to call the event listener, use the Device plugin to get the device model, set a variable (iOSversion = true) and then use that variable when we build the UI.
We can't get it working.
We're using jQuery Mobile so everything is in a
$(document).ready(function(
This has
document.addEventListener("deviceready", false);
in it, as well as the rest of our scripts and the UI initialisation scripts. jQM is the template, but we're building content and UI components based on JSON data. Up until this point it's all been fine.
The problem is the UI initialisation script seems to start BEFORE the event listener has finished doing whatever it does and so iOSversion is never, ever true by the time the UI script runs.
Yes, we could call it from onDeviceReady in:
document.addEventListener("deviceready", onDeviceReady, false);
but then we can't test in the browser.
I'm sure there is some simple solution to this that I'm missing, but we've been at it for a day now and it's the final hurdle and has got everyone really frustrated.