Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i see what is the current/live page in jquery-mobile?

I need to find out what page is loaded in query mobile for a javascript script. I have been looking at: $.mobile.activePage but can't seem to work out how.

It would be good to have: if($.mobile.activePage = "#page"){

like image 604
jimbo Avatar asked Sep 20 '11 19:09

jimbo


People also ask

What happened to jQuery Mobile?

jQuery Mobile is no longer supported.

Do people still use jQuery Mobile?

jQuery Core is still actively maintained and widely implemented.

What does jQuery Mobile use to handle page events?

However, in jQuery Mobile, Ajax is used to load the contents of each page into the DOM as you navigate, and the DOM ready handler only executes for the first page. To execute code whenever a new page is loaded and created, you can bind to the pageinit event.


2 Answers

$.mobile.activePage returns a jQuery object. SO you should probably try something like this:

if($.mobile.activePage.attr("id") == "page"){
like image 58
Femi Avatar answered Apr 02 '23 08:04

Femi


You can get the currently active page by using $.mobile.activePage

If you want to test that a selected jQuery element is the current page you could look for the existence of the "ui-page-active" class:

if ($("#myPage").is(".ui-page-active")) { ... }
like image 29
InvisibleBacon Avatar answered Apr 02 '23 10:04

InvisibleBacon