如何使當我嘗試從一個頁面導航到另一個頁面(單頁面模板)時顯示JQM加載消息?jquery mobile changepage在更改頁面時加載消息()
截止目前,我在changePage發生之前致電$.mobile.loading("show");
。
我試過this和this中的方法,但它仍然不起作用。我只需點擊源頁面上的按鈕即可使用changePage。上述鏈接中提供的方法僅適用於FF。不適用於Android,iOS本機瀏覽器以及Chrome或Safari。
哦,而且我正在使用JQM v1.2.0 stable。
編輯: 繼承人使用
$(".listview").live("click", function() {
$.mobile.loading('show', {
text: 'Please wait... Loading...',
textVisible: true,
theme: 'a',
textonly: true
});
var v1= $(this).attr("v1");
//var CourseID = "";
var v2= $(this).attr("v2");
var v3= $.trim($(this).children("h3").text());
var v4= $.trim($(this).find("span").children("span:first").text());
var v5= $.trim($(this).children("p:last").text());
$.ajax({
async: false,
type: "POST",
url: "//url of the webmethod//",
data: "{v1:" + v1+ ", p:" + id + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function (msg) {
ViewModel.variable1({ //binding data to ViewModel here//
});
$.mobile.changePage("#course-pg", { transition: "none" });
},
error: function (msg) {
$("#errorpopup").popup('open');
},
complete: function() {
$.mobile.loading('hide');
}
});
});
這很奇怪,當你自動調用changePage()時會顯示加載消息...你有[頁面加載小部件設置](http://jquerymobile.com/demos/1.2.0/docs/pages /loader.html)設置是否正確? –
@ZathrusWriter是的,我有。我已經將它添加到移動init中。js – krishgopinath
和您的'mobileinit'在頁面上之前,您包括jQuery Mobile JavaScript文件? –