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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:48:58+00:00 2026-05-30T06:48:58+00:00

I have a JQuery Mobile application and I seem to have several locations in

  • 0

I have a JQuery Mobile application and I seem to have several locations in the app where the JavaScript doesn’t execute as expected. In short, I have a “Dashboard” page. If the user hasn’t logged in, I use the “changePage” function to send them back to the Login page.

If I attempt to login directly via the Login page, everything works as expected. However, if I am redirected to the Login page from the Dashboard page, I see a JavaScript error that says: “loginButton_Click is not defined”. To provide more insight, here is my code:

Dashboard.html

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />

    <script src="/jquery-1.6.4.min.js" type="text/javascript"></script> 
    <script type="text/javascript" src="/scripts/shared.js"></script>
    <script src="/scripts/jquery.mobile-1.0.1.min.js" type="text/javascript"></script>
</head>

<body>
  <div id="dashboardPage" data-role="page">
    <div data-role="header">
      <a id="logoutButton" href="#" class="ui-btn-left jqm-home">Logout</a>
      <h1>My App</h1>
    </div>

    <div data-role="content">
      <ul data-role="listview"> 
        <li data-role="list-divider"><span id="greeting"></span></li>
      </ul><br />
    </div>
  </div>
</body>
</html>

Shared.js

$("#dashboardPage").live("pagecreate", function () {
});

$("#dashboardPage").live("pagebeforeshow", function () {
});

$("#dashboardPage").live("pageshow", function () {
    var user = window.localStorage.getItem("user");
    if (user == null) {
        $.mobile.changePage("/login.html", { transition: "slide" });
    }
});

login.html

<html>
<head>
    <meta charset="utf-8" />
    <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />

    <script src="/jquery-1.6.4.min.js" type="text/javascript"></script> 
    <script type="text/javascript" src="/scripts/shared.js"></script>
    <script src="/scripts/jquery.mobile-1.0.1.min.js" type="text/javascript"></script>
</head>

<body>
  <div id="loginPage" data-role="page">
    <div data-role="header"><h1>App Name</h1></div>

    <div data-role="content">
      <label for="usernameTextBox">Username</label>
      <input id="usernameTextBox" type="text" /><br />

      <label for="passwordTextBox">Password</label>
      <input id="passwordTextBox" type="password" /><br />

      <input type="button" value="Login" onclick="return loginButton_Click();" />
    </div>
  </div>

  <script type="text/javascript">
   function loginButton_Click() {
      $.mobile.changePage("/dashboard.html", { transition: "slide" });
   }
  </script>
</body>
</html>

I feel like there is something that I don’t understand regarding how JavaScript gets into the DOM. What am I doing wrong?

  • 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-30T06:49:00+00:00Added an answer on May 30, 2026 at 6:49 am

    In shared.js add $(…) wrapper:

    $(function(){ 
    
    $("#dashboardPage").live("pagecreate", function () {
    });
    
    $("#dashboardPage").live("pagebeforeshow", function () {
    });
    
    $("#dashboardPage").live("pageshow", function () {
        var user = window.localStorage.getItem("user");
        if (user == null) {
            $.mobile.changePage("/login.html", { transition: "slide" });
        }
    });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single page jQuery mobile application that consists of several list views
I have a single page jquery mobile application in which there are few parent
I am creating one application with jquery.mobile-1.0a4.1 release. I have a page which is
I have a popup select box in a form in my jQuery Mobile application.
I have a form in a Code Igniter view in my jQuery Mobile application.
I have an application made by using phonegap 1.5.0 and jquery mobile 1.1.0.... I
I have a question. When i am creating an application in rhomobile jquery.mobile.structure-1.0.css present
I have a Jquery Mobile page. In my header I have a button to
I have a jquery mobile web app. On my iPhone when I am on
I have been working with jQuery mobile 1.0.1. I have a page which drills

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.