I need to get the id of the element of the active page loaded jquery-mobile. I know what we can use $.mobile.activePageto get the current page in sight, and that we can get the identifier of this element with $.mobile.activePage.attr('id'). However, this is the first time you download the application undefined. In my specific application, I want users to be able to type from any URL, and I need to know the loaded page in order to properly initialize my navigation system.
$(document).bind('pageinit', function() {
if($.mobile.activePage !== undefined) {
console.log($.mobile.activePage.attr('id'));
}
else {
console.log('1st page load detected');
}
});
Outputs: 1st page load detected upon first loading and identifier on each subsequent page. How can I get the identifier on first boot?!?
Adam source
share