changePage "jumps" back to old page

Ueli picture Ueli · Jan 8, 2013 · Viewed 7.7k times · Source

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.

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.

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

Thank you very much

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

Answer

Carlos Duque Yemail picture Carlos Duque Yemail · Jul 10, 2013

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>

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.