[英]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: 所以我有一个listview,其中每个组件都连接到一个on click函数,如下所示:
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.
当我在firebug中检查页面时,没有加载任何必要的JS文件。 On top of this, it doesn't seem like the $(document).ready function is ever getting executed.
最重要的是,它似乎不会执行$(document).ready函数。 Does anyone have any insight as to what I am doing wrong?
有没有人对我做错了什么有任何见解? Sorry, I am a bit new to JQ... Thanks in advance.
对不起,我对JQ有点新鲜......提前谢谢。
<!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>
You cannot start the jQuery mobile with $(document).ready()
you should started like this: 你不能用
$(document).ready()
来启动jQuery mobile你应该像这样开始:
try to work with this in the first HTML 尝试在第一个HTML中使用它
$("div[data-role*='page']").live('pageshow', function(event, ui) {
document.location.href="newPage.html";
});
Geoff, if you are using the Beta 3 version of the JQM framework, read this . Geoff,如果您使用的是JQM框架的Beta 3版本, 请阅读此内容 。 It will help shed light on the DOM and $(document).ready().
它将有助于阐明DOM和$(文档).ready()。 You may want to consider the "pagecreate" and "pagebeforecreate" events.
您可能需要考虑“pagecreate”和“pagebeforecreate”事件。 They are delineated in the doc referenced in the above link.
它们在上述链接中引用的文档中描述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.