Arun.DotNet
Arun.DotNet

Reputation: 81

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

we are developing mobile app using jquery mobile & phonegap for various customers. Almost all the requirement completed but current requirement is each customer expecting different structure of html. how to make this possible satisfy the requirement?

i can duplicate of all pages and change the structure of html based on customers. 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.

Thanks in Advance

Upvotes: 1

Views: 266

Answers (1)

Nirmal Patel
Nirmal Patel

Reputation: 5168

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 @includes to incorporate fragments of reusable JSP in a master page.

2) Use a template engine to place client-specific HTML fragments. 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. You will have to ensure that you do this before JQM begins its own life-cycle and fires its init events.

4) Use a Ant build script to do a client specific build using Ant's replace and token match tasks. YMMV with this approach based on the complexity of rules you need to check to create a page. 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.

Upvotes: 1

Related Questions