Jquery Mobile - Multi-page structure

    In this post today, we will have a look at the multi-page Jquery mobile architecture. We have discussed the single page architecture in detail in the previous post. In case you have missed it, I recommend you to have a look at it first, before you proceed to the Jquery Mobile Multi-page architecture.

    Jquery multi-page architecture is nothing but a collection of DIVs stacked together in a single HTML page linked to each other using the div IDs. Let's take a look at the example below and then discuss it in detail. The example shows a three "page" site built with 3 jQuery Mobile divs navigated by linking to an id placed on each page wrapper. Note that the id's on the page wrappers are only needed to support the internal page linking, and are optional if each page is a separate HTML document. Here is what three pages look inside the body element.

    You must have observed that each of the page div has an attribute data-role="page" and an id associated with it. Each page is required to have a unique id which is used to link these pages together. When a link is clicked, the Jquery Mobile framework will look for an internal page with that id and transition the page into view. Another thing to remember is that the id attribute of all your elements must be not only unique on a given page, but also unique across the pages in a site. This is because jQuery Mobile's single-page navigation model allows many different "pages" to be present in the DOM at the same time. This also applies when using the multi-page template, since all the "pages" on the template are loaded at the same time.

UPDATE: The following example makes use of the next stable version of Jquery Mobile 1.3.1

   Hope the single page and multi-page jQuery mobile structures are clear. However, there is a small problem with the multi-page structure approach that you might face while implementing it. How to have a different page title for all the pages that are stacked in one single HTML? There is a simple solution to this which JQuery Mobile has provided us with and we will discuss it in the next post.

    Hope you followed this post and it has helped you. Stay tuned for more such code samples and snippets.

Popular posts from this blog

Where does Google get it's live traffic data from?

jQuery Mobile's Next Big Step

Geodesic Polyline