构建 PhoneGap jQuery Mobile 应用程序 [英] Structuring a PhoneGap jQuery Mobile Application
问题描述
我目前正在使用 jQuery Mobile 框架在 phonegap 中构建游戏.我最终得到的是大量带有一个 html 和几个 js 类的意大利面条式代码.
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.
我很想知道是否有任何好的指南来创建遵循 MVC 模式的结构化 jQuery 移动应用程序.
I was interested to know if there are any good guides to create a structured jQuery Mobile Application that follows MVC pattern.
我找到了一个关于创建 MVC 应用程序的很好的指南用煎茶触摸.我正在寻找与 jQuery Mobile 类似的东西.
I found a good guide for creating a MVC App with Sencha Touch. I was looking for something similar with jQuery Mobile.
推荐答案
我有一个相当大的应用程序,这就是我的结构
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
除了我的 index.html 文件之外,所有其他 .html 文件都是存根.它们仅包含 <div data-role='page'></div>
和其他定义页面及其预期功能所需的 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.
我在 VS2010 上开发应用程序,使用 Chrome 作为我的调试器.当我对自己的进步感到满意时,我会将所有内容复制到我的 Mac 中的一个 Eclipse 项目(对于 Android 设备)中的文件夹,这也是我的 xCode 项目(对于 iOS 设备)中的链接引用.
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 ).
我已经在这个项目上工作了大约 3-4 个月,一旦我通过了 jQM 和 PhoneGap 的学习曲线,就在这个结构上取得了很好的进展.
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.
这篇关于构建 PhoneGap jQuery Mobile 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!