私はJQMが初めてです。たとえば、divタグを使用して多くのページを作成したファイルindex.htmlがあります
<div data-role="page" id="pg1 "></div>
今、ページIDを使用して特定のページをリロードしたい.. location.reload() を使用してこれを行う方法、またはその他の方法??
ありがとう..
私はJQMが初めてです。たとえば、divタグを使用して多くのページを作成したファイルindex.htmlがあります
<div data-role="page" id="pg1 "></div>
今、ページIDを使用して特定のページをリロードしたい.. location.reload() を使用してこれを行う方法、またはその他の方法??
ありがとう..
すべての疑似ページが 1 つのドキュメントにあるマルチページ テンプレートを使用している場合、ページは現在の DOM にしか存在しないため、デフォルトではページを更新できません。AJAX リクエストで同じドキュメントをリクエストし、レスポンスから疑似ページを取得して DOM の現在のページを置き換える関数を作成できます。
function replace_multipage_template (SELECTOR) {
//show the loading spinner
$.mobile.showPageLoadingMsg();
$.ajax({
//request the same document as the current URL
url : window.location.href,
success : function (response) {
//select just the desired pseudo-page
var $ele = $(response).find(SELECTOR);
//replace the current pseudo-page with the new one
$(SELECTOR).replaceWith($ele);
//hide the loading spinner
$.mobile.hidePageLoadingMsg();
//navigate to the refreshed pseudo-page
$.mobile.changePage($ele);
},
error : function (jqXHR, textStatus, errorThrown) { /*make sure to handle errors*/ }
});
}
click
更新するページにユーザーを誘導するリンクのイベントのイベント ハンドラーで、このコードを使用できます。
//bind via delegation to the click events for links that target a specific pseudo-page
$(document).delegate('a[href="#some-page-id"]', 'click', function () {
//call the function from above, using the HREF attribute as the SELECTOR variable
replace_multipage_template($(this).attr('href'));
//prevent the default behavior of the link
return false;
});
http://jquerymobile.com/test/docs/api/methods.html
reloadPage オプションを指定して $.mobile.changePage メソッドを使用する