Bootstrap

Best way to reset form in Bootstrap Popup modal after modal close

Best way to reset form in Bootstrap Popup modal after modal close

Views

Hello, welcome to therichpost.com. In this post, I will tell you, Best way to reset form in Bootstrap Popup modal after modal close. Bootstrap is the most popular front-end framework.

I was facing one problem that, how to reset form in Bootstrap Popup modal after modal close? and I tried all the ways but I did not get any success then I got one jquery trick in mind and I will share that today and this one esay and clean.

Here is the trick for reset form in Bootstrap Popup modal after modal close:
//Code for open bootstrap modal pop up

var modalHtml = ""; // this is varibale, in which we will save modal html before open

$("#btnId").on('click', function() {
   modalHtml = $("#modalpop").html();
   $("#modalpop").modal("show");
});


//Code for close bootstrap modal popup

$("#modapop").on("hidden.bs.modal", function () {
    //here you can get old html of you modal popup
    $("#modalpop").html(modalHtml);// In this, we are adding old html in modal pop for achieving reset trick
});

 There are so many code in bootstrap and I will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Positive SSL