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 6093861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:36:35+00:00 2026-05-23T12:36:35+00:00

In order to load a jQuery mobile page using an anchor tag, one just

  • 0

In order to load a jQuery mobile page using an anchor tag, one just gives the page div’s id as the href

<a href="#page2">My link</a>
<div data-role="page" id="page2">
    <div data-role="header"></div>
    <div data-role="page"></div>
    <div data-role="footer"></div>
</div>

But this assumes that the page div was already loaded into the DOM. What if you want to generate pages and put them into the DOM like so:

$("body").append(newPageDivHTMLString);

I am trying to do it but keep getting a “Cannot call method _trigger of undefined”.

Stepping through the jQuery mobile (beta 1) source code, I found on line 2600 the following code:

page = settings.pageContainer.children( ":jqmData(url='" + dataUrl + "')" );

where pageContainer is the HTML body element and dataUrl is my page div’s id. This computes to undefined and seems to be the source of my problem. Is it possible currently to insert a page div into a jQuery mobile page, in the manner that I am?

Thanks for reading a long question. 🙂

  • 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-05-23T12:36:35+00:00Added an answer on May 23, 2026 at 12:36 pm

    I just tested on my local machine and this works for me:

    <html>
    <head>
    
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css" />
    
    <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
    
    <script src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>
    
    <script>
    
    function create_page(page_name) {
        $('body').append('<div data-role="page" id="' + page_name + '"><div data-role="content">Some content in here.</div></div>');
        //EDITED OUT, SEE BELOW $.mobile.changePage($('#' + page_name));
    }
    
    </script>
    </head>
    <body>
    
    
    
    <div data-role="page">
    <div data-role="content">
    <a href="javascript:create_page('test_page_name');" data-role="button" style="padding:15px; font-size:30px;">TEST TEXT</a>
    </div>
    </div>
    
    </body>
    </html>
    

    —-EDIT—-
    also have this function:

    function change_page(page_name) {
       $.mobile.changePage($('#' + page_name));
    }
    

    and use it to change to the dynamically created pages like so:

    <a href="javascript:change_page('test_page_name');" data-role="button" style="padding:15px; font-size:30px;">Change Page</a>
    

    There was some strange behavior with trying to link to the dynamically created page using a hash (href=”#test_page_name”). In firebug I saw that the create a page function properly appended the new page onto the body, but the change page button would create another page with the same id as the original page but a data-url that was set properly. The data-role=page div created by clicking on the change page link also had the same content as the first div, and the page created by the create_page function was just ignored.

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

Sidebar

Related Questions

I am using jQuery to load some data inside a div, after posting some
New question, but really close to need to refresh page in jquery mobile .
I am creating a webapp for iPhone using jQuery Mobile and PhoneGap. Everything works
I have a document that loads some content into a div with JQuery's .load()
Just a simple question, for the jQuery event. Are the .load(), .ready() and .unload()
For some specific reasons, I need to use the jQuery 'load()' method in order
I'm trying to dynamically create a form using JQuery. In order to do this,
I'm using jQuery UI's Dialog. In order to very nicely wrap the window around
I use the following code in functions.php in order to load jQuery and set
I'm using a jQuery toggle effect from Sohtanaka in order to 'show' and 'hide'

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.