ali*_*igf 13 javascript jquery-mobile
这就是我试图挂钩到mobileinit事件的方式:
$(document).bind("mobileinit", function() {
console.log("Mobile init");
});
Run Code Online (Sandbox Code Playgroud)
但这不适用于Chrome(最新版本),Ripple v0.9.1以及运行OS7.0的BlackBerry bold 9790.
注意:我也尝试使用.on()而不是.bind()运气.两个jQuery移动版本(1.0.1和1.1.0)都失败了.
CWS*_*ear 47
我用过这个,它确实有效.
是否可能有其他东西破坏脚本或者mobileinit没有被解雇?
Chrome是否会触发mobileinit?
我刚刚发现了一些我在jQuery Mobile 1.0中使用的代码,我们刚刚升级到1.1.0并且它可以运行.
你确定还要包含常规的'jQuery',对吧?
jQueryMobile的文档做到了,所以我确信它有效.别的一定是错的.对不起,我帮不了多少.你还有其他信息吗?或尝试使用其他设备.
[edit]在同一个自我页面上,它说"因为mobileinit事件是立即触发的,所以你需要在加载jQuery Mobile之前绑定你的事件处理程序.按以下顺序链接到你的JavaScript文件:"
<script src="jquery.js"></script>
<script src="custom-scripting.js"></script> <!-- Note your script before jqm -->
<script src="jquery-mobile.js"></script>
Run Code Online (Sandbox Code Playgroud)
看起来脚本顺序很重要.
这是另一个与我合作的简单示例(适用于android和ios)
<script type="text/javascript" src="files/resources/lib/jquery/jquery-1.8.2.js"> </script>
<script type="text/javascript">
$(document).bind("mobileinit", function()
{
if (navigator.userAgent.toLowerCase().indexOf("android") != -1)
{
// your logic here
$.mobile.defaultPageTransition = 'none';
$.mobile.defaultDialogTransition = 'none';
}
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1)
{
// your logic here
$.mobile.allowCrossDomainPages = true;
$.support.cors = true;
}
});
</script>
<script type="text/javascript" src="files/resources/lib/jquerymobile/1.3.2/jquery.mobile-1.3.2.js"></script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16519 次 |
| 最近记录: |