Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Mobile - $(document).ready not firing

So I have a listview in which each component wired to an on click function which looks like this:

function launchNewPage() {
    $.mobile.changePage( "newPage.html", { transition: "slide"} );
}

The problem I am encountering has to do with the next page. The page shows up just fine, but none of the resources are loading. When I inspect the page in firebug, none of the necessary JS files are loaded. On top of this, it doesn't seem like the $(document).ready function is ever getting executed. Does anyone have any insight as to what I am doing wrong? Sorry, I am a bit new to JQ... Thanks in advance.

Requested HTML:

<!DOCTYPE html> 
<html>
<head> 
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1"> 
    <title></title> 

    <link rel="stylesheet" href="CSS/JqueryMobile.css" />
    <link rel="stylesheet" href="CSS/theme.css" />  
    <link rel="stylesheet" href="CSS/JQM-DatePicker.css" /> 

    <script type="text/javascript" src="JS/jquery-1.6.2.js"></script>
    <script type="text/javascript" src="JS/JqueryMobile.js"></script>       
    <script type="text/javascript" src="JS/JQM-DatePicker.js"></script>

    <script type="text/javascript" src="JS/mockjax.js"></script>    
    <script type="text/javascript" src="JS/soyutils.js"></script>
    <script type="text/javascript" src="JS/fields.js"></script>
    <script type="text/javascript" src="JS/JSDictionaryObject.js"></script>
    <script type="text/javascript" src="JS/AddingForm.js"></script>
</head> 
<body> 
    <div id="page" data-role="page" data-theme="x">
        <div class="ui-body-x" data-role="header" data-position="fixed">
            <h1 class="ui-header-style" style="text-align:left; margin-left:10px;">Add New Record</h1>
            <div data-type="horizontal"  class="ui-btn-right ui-button-group"> 
                <a id="cancelButton" href="http://www.google.com" data-role="link"  data-ajax="false">Cancel</a>
                <a id="submitButton" form="f" class="ui-btn-up-x" onClick="javascript:return submitPressed();"data-role="button" data-icon="" data-ajax="false">Submit</a> 
            </div>              
        </div><!-- /header -->

        <div data-role="content" data-theme="x">

            <form  id="f" src="#"></form>       
        </div><!-- /content -->

    </div><!-- /page -->

</body>

like image 435
gabaum10 Avatar asked Feb 22 '23 23:02

gabaum10


1 Answers

You cannot start the jQuery mobile with $(document).ready() you should started like this:

try to work with this in the first HTML

$("div[data-role*='page']").live('pageshow', function(event, ui) { 
    document.location.href="newPage.html";
});
like image 159
Jorge Avatar answered Mar 04 '23 07:03

Jorge