I'm programming an iPhone app with Phonegap. I have local .html
and .js
files. The following is in my index.html
file:
function onBodyLoad() {
document.addEventListener("deviceready", deviceReady, false);
}
function deviceReady() {
$.getScript("js/order.js");
}
I researched and researched, but just can't figure out why my "order.js" file isn't getting called by the $.getScript
method. Any ideas? Or is there any other way to call this .js
file within the deviceReady function in my index.html
?
For me the following solution worked very well.
Add a custom jQuery function that uses ajax and caches the loaded script:
Import the scripts and optionally handle
done
andfail
:Thats it : ) More information may be found here.