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.
Get jQuery Mobile: Up and Running now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.