What is the correct way (to this date) to use JQuery Mobile and Phonegap together?
Both frameworks need to load before they can be used. How can I be sure that both are loaded before I can use them?
What is the correct way (to this date) to use JQuery Mobile and Phonegap together?
Both frameworks need to load before they can be used. How can I be sure that both are loaded before I can use them?
Here's how it worked for me, based on the example above
I believe that it isn't necessary to use the deferred feature. (Maybe this isn't necessary with newer versions of phonegap?) I have this in the head of my index.html file and everything works fine. I do think that the order of including jquery, phonegap and jquery mobile are important.
In order to use phonegap along with jquery mobile, you need to use it like this
The following worked for me on PG 2.3 and JQM 1.2, incl. Facebook Connect Plugin:
As many people suggested using a deferred is an okay option as long as you don't care what order
deviceready
andmobileinit
happe in. But in my case, I needed a fewpageshow
events when the application first loaded andmobileinit
and by extension thosepageshow
/pagebeforeshow
/etc events were all firing beforedeviceready
finished, so I couldn't bind to them properly using a deferred on them. This race condition was not a good thing.What I needed to do was make sure 'mobileinit' didn't take place until after '
deviceready
' was already fired. Becausemobileinit
fires immediately when you load JQM I chose to usejQuery.getScript
to load it AFTERdeviceready
was already finished.The reason I'm hiding the body is that a side effect of this method is a half second of visibility of the original HTML document before jquery.mobile loads. In this case hiding it an extra half second of empty space is preferred to seeing the unstyled document.
this is work for me. base on dhaval,this sample when I learn using sqlite