jQuery mobile: How to invoke this (default) error loading page message?

有些话、适合烂在心里 提交于 2019-12-18 17:29:11

问题


I am building RESTful mobile app and I like the default behaviour when resource is not found. jQuery Mobile shows this:

However, when I do my custom AJAX in onError (because resource is not found) I'd like to show fancy message (however, nothing happens in my code, default behavior is ignored):

$("#some-place").bind("pageshow", function() {
    $.ajax({
        type: "POST",
        url: "some-place/places.json",
        cache: false,
        dataType: "json",
        success: onSuccessInitPlaces,
        error: onErrorInitPlaces
    });
    return false;
});

function onSuccessInitPlaces(data, status) {
    // do stuff, not important atm
} 

function onErrorInitPlaces(data, status) {
    // pseudocode I'd like to invoke for real
    // should show attached picture 
    invokeFancyErrorLoadingPage();
}

回答1:


//show error message
$( "<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h1>YOUR MESSAGE</h1></div>" )
  .css({ "display": "block", "opacity": 0.96, "top": $(window).scrollTop() + 100 })
  .appendTo( $.mobile.pageContainer )
  .delay( 800 )
  .fadeOut( 400, function() {
    $( this ).remove();
  });


来源:https://stackoverflow.com/questions/8267159/jquery-mobile-how-to-invoke-this-default-error-loading-page-message

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