Playtime with Cordova: pt.3 jQuery Mobile integration

July 18, 2014

DISCLAIMER: This is me sharing my learning, I have not yet created a final application, and also, some of the process’ below may not be best practice. BUT as a place to start playing, which is really what we all want to do, I think it works.

Just look at the speed we are getting through this, you now have a development environment, and an application template that you are ready (and able) to test with. Next we start with the fun of tweaking it. Now, as with all things web, there are 101 ways of doing this, you could write from scratch, or maybe use one of the new frameworks like backbone/angular/ember. I opted for jQuery mobile though, it is well suited to the job at hand, but more importantly, there is a very small learning curve as I use jQuery at least once a week in regular Drupal development. Note that jQuery mobile may be considered overkill as it can be bloated, once you have built your application, you should always re-download jQuery and jQuery mobile so it only has the functionality you require.

Now, I did some tweaking, and thought I was getting somewhere. But the best place to start is with a little YouTube set of videos by ‘App-O-Mat’, check them out here https://www.youtube.com/watch?v=rW0Trnx7Yjo

To be honest, that will get you started really quite nicely, just go back over pt 2 of this series and see it work. But that said, I am a man wholearns through repetition and working things out, so you may want to do the same. Just go and build some new pages and link to them.

Okay, I think I may stop there for this post, if you want some reading before the next part, have a read of this, as we will be doing some dynamic generation of pages soon using data from a csv file (both local, and a remote one).

http://demos.jquerymobile.com/1.1.1/docs/pages/page-dynamic.html

The main things to take home in there are how the ‘pagebeforechange’ binding is required, aswell as the ‘enhancement’ parts. The enhancements are needed, as it triggers the jQuery mobile functionality to get all the layouts and listeners behaving on your new page as if it was hard coded.

Useful resources