Jquery mobile 使用PhoneGap进行闪烁导航的Jquery移动代码

Jquery mobile 使用PhoneGap进行闪烁导航的Jquery移动代码,jquery-mobile,cordova,Jquery Mobile,Cordova,我相信这个帖子能解决我的问题 . 具体而言: $(document).bind("mobileinit", function() { if (navigator.userAgent.indexOf("Android") != -1) { $.mobile.defaultPageTransition = 'none'; $.mobile.defaultDialogTransition = 'none'; } }); 我来自C#world,对jQuerymo

我相信这个帖子能解决我的问题 . 具体而言:

$(document).bind("mobileinit", function()
{
   if (navigator.userAgent.indexOf("Android") != -1)
   {
     $.mobile.defaultPageTransition = 'none';
     $.mobile.defaultDialogTransition = 'none';
   }
});

我来自C#world,对
jQuery
mobile几乎一无所知。我想添加这个片段,但不确定在哪里。如果有关系的话,我想我会将它添加到jquery.mobile-1.1.0.rc.1.js中,但是我不知道它在哪里,如果那是正确的文件。

必须在包含jquery核心之后和包含jquery mobile之前运行此代码。原因是要运行代码,jQuery必须存在,但在jQuery Mobile初始化之前需要绑定此事件处理程序

例如:

<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script>
$(document).bind("mobileinit", function()
{
   if (navigator.userAgent.indexOf("Android") != -1)
   {
     $.mobile.defaultPageTransition = 'none';
     $.mobile.defaultDialogTransition = 'none';
   }
});
</script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script>
if (navigator.userAgent.indexOf("Android") != -1)
{
    $(document).bind("mobileinit", function()
    {
      $.mobile.defaultPageTransition = 'none';
      $.mobile.defaultDialogTransition = 'none';
    });
}
</script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
资料来源:

作为一般观察,我注意到您将
if/then
语句放在事件处理程序中,您也可以将其放在外部,因此如果它不是Android设备,则事件绑定/触发就不必发生

例如:

<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script>
$(document).bind("mobileinit", function()
{
   if (navigator.userAgent.indexOf("Android") != -1)
   {
     $.mobile.defaultPageTransition = 'none';
     $.mobile.defaultDialogTransition = 'none';
   }
});
</script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script>
if (navigator.userAgent.indexOf("Android") != -1)
{
    $(document).bind("mobileinit", function()
    {
      $.mobile.defaultPageTransition = 'none';
      $.mobile.defaultDialogTransition = 'none';
    });
}
</script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>

if(navigator.userAgent.indexOf(“Android”)!=-1)
{
$(document).bind(“mobileinit”,function()
{
$.mobile.defaultPageTransition='none';
$.mobile.defaultDialogTransition='none';
});
}

我确实有同样的问题,而且在线解决方案似乎都不起作用。我正在测试一款搭载安卓2.3.6的galaxy mini,就用户体验而言,fade甚至非常糟糕

摆弄我的代码,出于运气,我发现这在某种程度上提高了我的性能

$(document).on("mobileinit", function(){
        $.mobile.defaultPageTransition = 'slide';
        $.mobile.transitionFallbacks='none';
});

就像奇迹一样,没有闪烁!偶尔会出现一些小故障,但肯定比以前好

哇!这是非常冗长和非常有用的!非常感谢。至于代码的位置……啊,这说明我知道的太少了。我本来想把它放在一个js文件中,但实际上它是内嵌在html文档中的。@user1278561您可以将代码放在jQuery核心文件的末尾,因为此时jQuery核心可以进行事件绑定,但jQuery Mobile还没有初始化。我刚刚注意到您使用的是jQuery Mobile 1.1.0 RC-1,您确实应该更新到1.1.0最终版本: