Skip to Main Content
jQuery Mobile: Up and Running
book

jQuery Mobile: Up and Running

by Maximiliano Firtman
February 2012
Beginner to intermediate content levelBeginner to intermediate
272 pages
6h 20m
English
O'Reilly Media, Inc.
Content preview from jQuery Mobile: Up and Running

Changing Page Contents

If we change a large group of HTML including lots of widgets, for example, creating various collapsible elements based on a JSON file received by AJAX, we have to refresh the whole container. The same happens if, for example, we add a couple of input elements to a current form and we want them to be converted to widgets, as if they were in the page from the beginning.

To refresh a container, so every widget can check again if there are instances to create, we can trigger the create event on the page.

For example:

$("#content").html(newHTMLcontentWithWidgets);
$("#page1").trigger("create");

Every widget constructor is usually handling the page’s create event, so it will detect again if there are controls to create.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

jQuery Mobile

jQuery Mobile

Jon Reid

Publisher Resources

ISBN: 9781449331085Supplemental ContentErrata Page