在 jquery 移动页面上初始化对象的正确方法是什么?这事件文档 http://jquerymobile.com/test/docs/api/events.html说使用“pageInit()
" 没有该函数的示例,但给出了绑定到 " 的示例pageinit
“方法(注意大小写差异)。但是,在这个简单的测试页面中我根本没有看到事件触发:
<html>
<body>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.min.js"></script>
<div data-role="page" id="myPage">
test
</div>
<script>
$("#myPage").live('pageinit',function() {
alert("This never happens");
});
</script>
</body>
</html>
我缺少什么?我应该补充一点,如果你改变pageinit
到另一个事件,例如pagecreate
这段代码有效。
- - 更新 - -
This bug https://github.com/jquery/jquery-mobile/issues/2540在 JQM 问题跟踪器中标记为“已关闭”。显然,对于这是否正常工作,意见不一。
当我在页面 div 中嵌入脚本时它开始工作:
<body>
<div id="indexPage" data-role="page">
<script type="text/javascript">
$("#indexPage").live('pageinit', function() {
// do something here...
});
</script>
</div>
</body>
使用过的 jQuery Mobile 1.0RC1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)