简体   繁体   English

使用带有多个html页面的phonegap和jquery移动设备的正确方法

[英]Correct way to use phonegap & jquery mobile with multiple html pages

I have an application which uses jquery mobile and consists of a few html pages each with a few jquery page elements within them. 我有一个使用jquery mobile的应用程序,它包含几个html页面,每个页面都有一些jquery页面元素。 On a desktop browser it all works fine but when I load it on my android device (running 2.3) the first page looks fine, but whenever you click a link (lets say from index.html -> logged-in-menu.html jquery mobile doesn't seem to kick in and no stylings are applied. If I then go BACK to index.html from the current page then index.html is left unstyled. 在桌面浏览器上它一切正常但是当我在我的Android设备上加载它(运行2.3)时,第一页看起来很好,但每当你点击一个链接时(比如说来自index.html - > logged-in-menu.html jquery移动设备似乎没有启动,也没有应用任何样式。如果我从当前页面返回到index.html,那么index.html将保持原样。

So is there a correct way to move between separate html pages? 那么在不同的html页面之间移动是否有正确的方法? I don't get any browser errors so everything seems to be working fine but none of the styles or features of jqm are applied. 我没有得到任何浏览器错误,所以一切似乎都工作正常,但没有应用jqm的样式或功能。

Just so everyone is on the same page, the links use data-ajax="false" so they cause a complete page refresh (as this is required), the app can not work as a single page application so putting everything into one big html file is not an option. 只是所有人都在同一页面上,链接使用data-ajax =“false”,因此它们会导致完整的页面刷新(因为这是必需的),应用程序无法作为单个页面应用程序工作,因此将所有内容放入一个大的html中文件不是一个选项。

如果您没有获得样式,那么您可能缺少CSS文档,JS错误,或者您没有在新页面上正确构建HTML。

Another alternative is to break up the pages (and even panels within a page) into separate template .html files dynamically loaded and render them as needed. 另一种方法是将页面(甚至是页面中的面板)分解为动态加载的单独模板.html文件,并根据需要进行渲染。 See the tutorial on "creating mobile apps with KnockoutJS, PhoneGap, and jQuery Mobile" http://bit.ly/crmakopgjqm 请参阅“使用KnockoutJS,PhoneGap和jQuery Mobile创建移动应用程序”教程http://bit.ly/crmakopgjqm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM