Reputation: 435
I am currently building a game in phonegap using jQuery Mobile frame work. What i have ended up with is lots of spaghetti code with one html and several js classes.
I was interested to know if there are any good guides to create a structured jQuery Mobile Application that follows MVC pattern.
I found a good guide for creating a MVC App with Sencha Touch. I was looking for something similar with jQuery Mobile.
Upvotes: 13
Views: 7597
Reputation: 4937
I have a rather large application and this is how I have it structured
css
-- all css files
images
-- all image files
js
controller.js -- page events and element actions. Also contains PhoneGap specific methods
core
forms.js -- working with forms, saving info
mobile.js -- basic definitions, AJAX communications
encrypt.js -- encryption
global.js -- helper functions
storage.js -- database storage wrapper
cw
client.js -- a client object, > 400 lines of js code
Objects.js -- all other needed objects with <50 lines of js code each
question.js -- a question object, > 500 lines of js code
service.js -- a service object, > 700 lines of js code
jq
jquery-ui.min.js
jquery.min.js
jquery.mobile.min.js
phonegap-1.1.0.js
add_client.html
clients.html
client_list.html
index.html -- the only file that is structured like a real full html file
manager.html
schedule.html
service.html
aside for my index.html file, all other .html files are stubs. They only contain the <div data-role='page'></div>
and other needed html elements that define the page and its intended functionality.
I develop the app on VS2010, using Chrome as my debugger. When I feel good with my progress, I copy everything over to my mac to a folder in an Eclipse project ( for Android devices ) which is also a linked reference in my xCode project ( for iOS devices ).
I have been working on this project for about 3-4 months now and once I got past the learning curve of jQM and PhoneGap, have been making very good progress with this structure.
Upvotes: 19
Reputation: 1910
Have you seen the wiki entry?
and to see some code have a look @
Sample Application using jQuery Mobile and PhoneGap http://coenraets.org/blog/2011/10/sample-application-with-jquery-mobile-and-phonegap/
Upvotes: 3