0
我在初始化JQuery Mobile站点上的事件时遇到了一些问题,我只想看看我是否正确地做了这件事。这里是我的代码有点样子:JQuery Mobile:页面初始化事件时遇到问题
<!DOCTYPE html>
<html>
<head>
<title>My page</title>
<link rel="stylesheet" href="jquery.mobile-1.3.0-beta.1.css" />
<script src="jquery-1.9.0.js"></script>
<script src="jquery.mobile-1.3.0-beta.1.js"></script>
<script text/javascript>
function myFunction()
{
//do some code
}
</script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>Home</h1>
</div>
<div data-role="content" data-theme="f">
<p><a href="#next-page" data-role="button" data-transition="fade">2nd page</a></p>
</div>
</div>
<div data-role="page" id="next-page">
<div data-role="header">
<h1>2nd page</h1>
</div>
<div data-role="content" data-theme="f">
<script text/javascript>
$("#next-page").on("pageinit", function() {
myFunction();
});
</script>
</div>
</div>
</body>
</html>
出于某种原因,当我加载了第二页,我只是得到了AJAX加载图标,它不会停止加载。
另一件事是,我不想myFunction()
被调用,直到第二页被加载,这就是为什么我有第二页内的脚本。
任何帮助是非常赞赏:)
我的错,我现在纠正了这个问题。这不是我的实际代码,所以这不是问题。 – mrpopo
忽略拼写错误,这不是我的页面的问题,因为这只是我输入的代码来显示我的问题的示例 – mrpopo
然后,您的代码没有任何问题:http://jsfiddle.net/Gajotres/V4NyB/你可以看到它工作得很好。 – Gajotres