在jQuery Mobile的弹出窗口中输入一些文本并使用changePage刷新当前页面。之后打开它会在文本框中显示我之前输入的内容。如何刷新弹出窗口(请不要建议清空文本框的值)。
代码如下:
代码如下:
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
allowSamePageTransition
不会_刷新_页面。要刷新页面,您需要使用reloadPage: true
。 - Omarform
中,然后调用$("#formID")[0].reset();
。http://jsfiddle.net/Palestinian/n78sdeet/ - Omar