Jquery Mobile - $(文件)。还没有开火 [英] Jquery Mobile - $(document).ready not firing

查看:76
本文介绍了Jquery Mobile - $(文件)。还没有开火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个listview,其中每个组件都连接到一个on click函数,如下所示:

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"} );
}

我遇到的问题与下一页有关。该页面显示正常,但没有任何资源正在加载。当我在firebug中检查页面时,没有加载任何必要的JS文件。最重要的是,似乎$(document).ready函数不会被执行。有没有人对我做错了什么有任何见解?对不起,我对JQ有点新... ...提前致谢。

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.

<!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>

推荐答案

你不能用 $(文件).ready()启动jQuery手机你应该这样开始:

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

尝试在第一个HTML中使用它

try to work with this in the first HTML

$("div[data-role*='page']").live('pageshow', function(event, ui) { 
    document.location.href="newPage.html";
});

这篇关于Jquery Mobile - $(文件)。还没有开火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆