jquerymobile with backbone showing loading spinner

送分小仙女□ 提交于 2019-12-24 05:58:17

问题


I am using jQuery mobile with backbone

I have disabled the jquery mobile routing and use backbones which all works well

here is that config

define(['jquery'], function($){

$(document).bind("mobileinit", function () {
    $.mobile.ajaxEnabled = false;
    $.mobile.linkBindingEnabled = false;
    $.mobile.hashListeningEnabled = false;
    $.mobile.pushStateEnabled = false;
    // Remove page from DOM when it's being replaced
    $('div[data-role="page"]').live('pagehide', function (event, ui) {
        $(event.currentTarget).remove();
    });
});
});

then on my ajax calls for my views I use this code

     $.ajax({
            beforeSend: function() { $.mobile.showPageLoadingMsg(); },
            url: this.template,
            dataType: 'html',
            async: false,
            success: function(data) {
                compiled = _.template(data);
                $.mobile.hidePageLoadingMsg();
            }
        });

This shows the loader fine in firefox but does not work on chrome or my ios device?

can anyone help?

Thanks


回答1:


Webkit browsers like Chrome/safari/android/iOS have a problem with jQM and async: false ajax call. They will get locked while ajax call is processing. Firefox don't have such problem, for whatever reason.

Change:

async: false,

to:

async: true,

If async: false is crucial to you app functionality and you want to prevent user interaction while ajax is working, display a transparent div overlay over whole app. Do it in beforesend state and remove it in a success or a failure state.



来源:https://stackoverflow.com/questions/13985589/jquerymobile-with-backbone-showing-loading-spinner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!