在jquery mobile彈出窗口中輸入一些文字,使用changePage刷新當前頁面。之後,打開它顯示在文本框中我以前輸入的內容。如何刷新彈出窗口(請不要建議清空文本框的值)。刷新jquery mobile中的彈出窗口內容
的代碼是:
localStorage.setItem("name","tiger");
$(document).on("click","#save",function(){
$("#openpopup").popup("close");
localStorage.setItem("name",$("#pText").val());
$.mobile.changePage("#page1",{
allowSamePageTransition : true,
transition : 'none',
});
});
$(document).on("pageshow","#page1",function(){
if(localStorage.getItem("name")){
$("#name").val(localStorage.getItem("name"));
}
});
這裏是FIddle
「_Please不建議空文本框VALUE_」。沒有比重置輸入值更好的方法。 http://jsfiddle.net/Palestinian/wcLdkt0w/6/ – Omar 2014-09-26 08:04:44
@Omar謝謝您的回覆..i刷新(更改)頁面,即使彈出窗口未刷新..然後刷新(changepage)中沒有用處JQM .. – Vini 2014-09-26 08:11:57
檢查演示http://jsfiddle.net/Palestinian/wcLdkt0w/7/'allowSamePageTransition'不_refresh_頁。要刷新頁面,您需要使用'reloadPage:true'。 – Omar 2014-09-26 08:15:17