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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:27:05+00:00 2026-06-17T21:27:05+00:00

Hi (I may not be doing this correctly) – I am trying to and

  • 0

Hi (I may not be doing this correctly) – I am trying to and having problems navigating to a page in my JQuery Mobile (JQM) application when trying to load the page as a dialog using “changePage()”. I have looked around and have tried a few alternatives with no luck 🙁

E.g. I have a login page that opens successfully as a dialog on the application init:

$.mobile.changePage(page, {transition: 'pop', role: 'dialog' }); 

the login screen has a login button, which when clocked forwards to a normal (non dialog) page, again successfully and again using changePage:

$.mobile.changePage( page );

The problem occurs when I again try to load the login page in the dialog (e.g. when logging out). I have a logout button, which when clicked navigates back to the login page:

$.mobile.changePage(page, {transition: 'pop', role: 'dialog' }); 

However this time I get the following exception in the JQM lib: “Uncaught TypeError: Cannot call method ‘indexOf’ of undefined”

Here is some example code that recreates the problem:

<script type="text/javascript">

$(function()  {
    createPage("login");
});

function createPage( pageStr ) {  
    var page = $("<div id='pageWrapper' class='pageWrapper' data-role='page' ></div>");
    var header = createHeader( pageStr );
    var content = createContent( pageStr );

    page.append(header, content);

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

    if(pageStr == "login") {     
        $.mobile.changePage(page, {transition: 'pop', role: 'dialog' }); 
    }
    else {
        $.mobile.changePage( page );
    }
}

function createHeader( pageStr ) {
    var headerContainer = $("<div id='header' class='header' data-role='header' data-position='fixed'></div>");

    if(pageStr != "login") {
        var logOutButton = $("<a onclick='logout()' class='ui-btn-right' data-rel='dialog'>Logout</a>");
        headerContainer.append(logOutButton);
    }

    var headerTitle = $("<h1>Page: " + pageStr + "</h1>");
    headerContainer.append(headerTitle);
    return headerContainer;
}

function createContent( pageStr ) {
    var contentDiv = $("<div id='content' class='content' data-role='content'></div>");
    var contentBuilder = $("<div></div>");

    if(pageStr == "login") {
        contentBuilder.append(createloginForm());
    }
    else {
        contentBuilder.append(createWrapper());
    }
    contentDiv.append(contentBuilder);
    return contentDiv;
}

function createloginForm() {
    var form = $("<form id='loginForm' method='post'></form>");
    var loginButton = $("<p><input type='button' value='Login' onclick='login()'></input></p>");
    form.append(loginButton);
    return form;
}

function createWrapper() {
    var tmpText = $("<h2>some content ...</h2>");
    return tmpText;
}

function login() {
    createPage("main")
}

function logout() {
    createPage("login"); // pages[0] = login page
}

</script>

Thanks,
Jon.

  • 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-17T21:27:06+00:00Added an answer on June 17, 2026 at 9:27 pm

    thanks for the comment – I did not mention / include in the example, that I am cleaning the pages each time therefore no duplicate elements or ids are being added (only one page is added / rendered at any one time).

    I think I have fixed the problem by manually initialising the page before hanging it – not sure if its a “cosier” fix, but appears to work:

    Before calling the changePage() method, I need to first initialize the new page: E.mobile.initializePage();

    Thanks again,
    Jon.

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

Sidebar

Related Questions

I'm not a PHP developer so I may be doing something wrong. I'm trying
I fear this just may not be possible, but I'm trying to create a
I'm having trouble making a POST to the play framework - this may not
I don't often use background-position, so maybe I'm not doing this correctly, but my
I am not sure I am doing any of this correctly. Is it because
This may not be a programming question, but I don't know where to ask
This may not be the kind of question one should ask on StackOverflow, but
This may not be possible for the carousel but is there a way to
I think I may not understand correctly how array_splice is supposed to work. My
I don't think I am doing this correctly and problem is that because 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.