2014-09-26 77 views
3

在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

+0

「_Please不建議空文本框VALUE_」。沒有比重置輸入值更好的方法。 http://jsfiddle.net/Palestinian/wcLdkt0w/6/ – Omar 2014-09-26 08:04:44

+0

@Omar謝謝您的回覆..i刷新(更改)頁面,即使彈出窗口未刷新..然後刷新(changepage)中沒有用處JQM .. – Vini 2014-09-26 08:11:57

+1

檢查演示http://jsfiddle.net/Palestinian/wcLdkt0w/7/'allowSamePageTransition'不_refresh_頁。要刷新頁面,您需要使用'reloadPage:true'。 – Omar 2014-09-26 08:15:17

回答

3

要重置所有形式的元素,例如inputselect,checkbox等,你需要把它們包裝在form。然後重置表格$("#formID")[0].reset()一旦彈出被隱藏。

$("#popupID").popup({ 
    afterclose: function() { 
     $("#foo")[0].reset(); /* reset form */ 
    } 
}, "close"); 

Demo

+0

任何想法https: //stackoverflow.com/questions/26778652/not-able-to-close-the-jt-sage-date-picker-after-pick-date – Vini 2014-11-06 11:45:49