Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7957541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:15:54+00:00 2026-06-04T04:15:54+00:00

I need to get the ID of the active page element loaded by jquery-mobile

  • 0

I need to get the ID of the active page element loaded by jquery-mobile. I know that we can use $.mobile.activePage to get the current page in view and that we can get the ID of this element using $.mobile.activePage.attr('id'). However, it is undefined on first load of the application. In my particular application, I want users to be able to enter from any URL and I need to know the currently loaded page in order to properly initialise 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 on first load and the ID on every subsequent page. How can I get the ID on the first load?!?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:15:55+00:00Added an answer on June 4, 2026 at 4:15 am

    I think your problem is, that pageinit is too early to query for active page class.

    If you load the first page, pageinit will fire BEFORE the changePage to the first page is called (the first page is also loaded via a changePage call). Only @about line 3639 in JQM, the active page class gets assigned to the page.

    By that time, pageinit is long gone.

    If you want to grab the ID of the first page either use any other of the available page events:

    pagebeforeload = triggered before the load request (inside changepage) is made
    pageload = triggered after the page was loaded
    pagebeforechange = triggered before a changepage is made
    pagechange = triggered after changepage is done
    pagebeforeshow = triggered before the page is shown
    pageshow = triggered when the page is shown
    

    I would use pagebeforeshow, or if you want to tweak a lot of content, try pagechange or pagebeforechange.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the form element of the active page without using the
I need to get Current page Identifier and current module in Magento. I used
I need to get information on loaded data percentage when UIWebView loads page. I
Is there a way to get the active instance of the current page in
New question, but really close to need to refresh page in jquery mobile .
I need to get the contents from this URL http://google.fr/ok in a NSString can
I'm currently trying to use Quicksand, a jquery plugin that allows you to animate
I have a page that requires 2 divs to get fixed position once certain
I have a page that check a querystring and adds an active to the
I have an Active Server Page, which displays Booking of the current Day. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.