JQueryMobile 1.4 is deprecated in the showhow event and recommends using pagecontainershow instead; however, although I can get a pagecontainershow event at the document level, I cannot bind a function to a specific page.
<div id="page1" data-role="page"> ... <script> $( "#page1" ).on( "pagecontainershow", function( event, ui ) { console.log("page1 pagecontainershow"); } ); </script> </div>
Demo: http://jsbin.com/IFolanOW/22/edit?html,console,output
I also looked at using an alternative form of the jQuery "on" function, where we use a selector, but this should be the parent element of the page div, and this may include other pages, so this does not work.
As a workaround, I did this, but it is very inefficient:
function registerOnPageShow(pageId, func) { var strippedPageId = pageId.replace("#", ""); var e = "pagecontainershow." + strippedPageId;
jquery-mobile
Infofinity
source share