changePage“跳转"回到旧页面 [英] changePage "jumps" back to old page

查看:235
本文介绍了changePage“跳转"回到旧页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用jQuery Mobile应用程序时遇到了一个大问题: 我正在使用自定义功能(它们由onClick触发)来使用currentPage切换页面.

I've a big problem with a jQuery Mobile Application: I'm using custom functions (they are triggered by onClick) to switch the page with currentPage.

它仅在集成浏览器已更改(由于ajax请求)的网站上的Android设备上发生. iOS和Chrome效果很好.

It only happens on Android-Devices on sites in which has changed (due to ajax requests) with the integrated browser. iOS and Chrome works nice.

单击一个元素后,动画开始了,但是在动画结束之前,它会切换回旧页面.半秒钟后,它将切换回新的.

After clicking on an element, the animation started but just before it ends, it switches back to the old page. After a half second, it switches back to the new.

我在此处制作了有关该错误的电影: http://www.youtube.com/watch?v=sXxvVUxniNg

I made a movie of the bug here: http://www.youtube.com/watch?v=sXxvVUxniNg

非常感谢您

代码(CoffeeScript):

Code (CoffeeScript):

class Guide

    @categoriesLoaded = false

    @loadSearch: ->

        $.mobile.changePage $("#guide"),
            transition: 'slide'
            changeHash: false

        if !@categoriesLoaded

            @categoriesLoaded = true

            GuideApi.getCategories (data) ->
                output = Mustache.render $("#tmpl-guide-categories-select").html(), 
                    categories: data

                $("#guide-search-category").append output

                $("#guide-search-category").val($("#guide-search-category option:first").val());

window.WgSwitchGuide = ->
        Guide.loadSearch

推荐答案

我遇到了同样的问题.我尝试了一切,最后终于找到了解决方案.我发现的错误主要是在浏览器中.因此,我将pushStateEnabled的配置设置为false.我通过执行以下操作并添加了此脚本来做到这一点.

I was having the same issue. And I tried everything, I finally end with the solution. What I found was the error was principally within the browser. So I set the configuration of the pushStateEnabled as false. I did it by doing the following, adding this script.

<script type="text/javascript">
$(document).bind("mobileinit", function(){
$.mobile.pushStateEnabled = false;
});
</script>

应该在调用jquery-mobile脚本之前添加它,有关更多信息,您可以在

It should be add before the jquery-mobile script is call, for more information you could see it on JQuery description

它解决了问题,不再跳回去.

And it solved the problem no more jumping back.

这篇关于changePage“跳转"回到旧页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆