Refresh the popup contents in jquery mobile

In jquery mobile popup enter some text and refresh the current page using changePage. After that open the open it shows in the text box what i enter previously. How to refresh the popup(Please dont suggest empty the textbox value).

The code is:

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"));
}
});

Here is the FIddle

Answers


To reset all form elements, e.g. input, select, checkbox, etc at once, you need to wrap them in a form. And then reset the form $("#formID")[0].reset() once the popup is hidden.

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

Demo


Need Your Help

JPQL in clause with enum

hibernate jpa spring-boot jpql spring-jpa

I have application based on spring boot 1.2.3. One of the model is very specific: contains list of enums. When I try to call by spring jpa query part of sql disappear [c.categories IN (:category) is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.