简体   繁体   English

如何在jQuery mobile中的多个页面重用html代码?

[英]How to reuse html code for multiple pages in jquery mobile.?

we are developing mobile app using jquery mobile & phonegap for various customers. 我们正在使用jquery mobile和phonegap为各种客户开发移动应用程序。 Almost all the requirement completed but current requirement is each customer expecting different structure of html. 几乎所有已完成的要求,但当前的要求是每个客户都期望html的结构不同。 how to make this possible satisfy the requirement? 如何做到这一点满足要求?

i can duplicate of all pages and change the structure of html based on customers. 我可以复制所有页面,并根据客户更改html的结构。 But it difficult to maintain all these files i think so 但是我很难维护所有这些文件

in mvc we having partial view to achieve this, we expecting something same like partial view in html. 在mvc中,我们有部分视图来实现这一点,我们期望类似html中的部分视图。

Thanks in Advance 提前致谢

Here are couple of approaches I have used in the past in different situations, in decreasing order of my personal preference: 以下是我过去在不同情况下使用的几种方法,按照我个人喜好的降序排列:

1) Use JSP if your pages are going to live on the server and employ @include s to incorporate fragments of reusable JSP in a master page. 1)使用JSP ,如果你的页面是要住在服务器上,并采用@include s到纳入可重复使用的JSP的片段在母版页。

2) Use a template engine to place client-specific HTML fragments. 2)使用模板引擎放置客户端特定的HTML片段。 You will be interleaving your business rules in the template's query language. 您将使用模板的查询语言来交错业务规则。

3) Use Jquery if your pages are packaged in a client app and use $.load() to load fragments of HTML. 3)如果您的页面打包在客户端应用程序中,请使用Jquery并使用$.load()加载HTML片段。 You will have to ensure that you do this before JQM begins its own life-cycle and fires its init events. 您将必须确保在JQM开始其自己的生命周期并触发其init事件之前执行此操作。

4) Use a Ant build script to do a client specific build using Ant's replace and token match tasks. 4)使用Ant构建脚本使用Ant的replacetoken匹配任务来进行特定于客户端的构建。 YMMV with this approach based on the complexity of rules you need to check to create a page. 使用这种方法的YMMV根据您需要检查以创建页面的规则的复杂性。 Ant is just one option; 蚂蚁只是一种选择。 any other build tool will provide similar function. 任何其他构建工具都将提供类似的功能。

You will probably end up using multiple techniques from above for a complete solution. 您可能最终将从上面使用多种技术来获得完整的解决方案。

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

相关问题 引导程序中的Navbar可在移动设备上的4页中的2页上使用。 所有人的代码都一样 - Navbar in bootstrap works on 2 of 4 pages on mobile. Code is the same for all 带有类型文件的 HTML 'input' 标签在移动设备中不起作用。 如何解决? - HTML 'input' tag with type file is not working in mobile. How to fix it? HTML2Canvas 适用于桌面,但不适用于移动设备。 怎么修? - HTML2Canvas works on desktop but not on mobile. How to fix? 如何使用 Jquery 将一个 html 代码重用到另一个 html? - How to reuse one html code to another html using Jquery? 引导程序重用html标签在不同页面中的代码 - bootstrap reuse html tags code in different pages 是否可以在多个页面上像模板一样重用 HTML? - Is it possible to reuse HTML like a template on multiple pages? jQuery Mobile中的多HTML页面 - Multi HTML pages in jQuery Mobile 如何在使用不同的jQuery / PHP代码时重用HTML页面 - How to reuse HTML page while using different jQuery/PHP code 使用Phonegap,哪个更好:多个html页面或多个jquery-mobile页面? - With Phonegap, which is better: multiple html pages or multiple jquery-mobile pages? 网站没有像在移动设备上那样显示。 如何解决这个问题呢? - Website not appearing as it is on mobile. How to solve this problem?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM