Home 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

by therichpost
1 comment
bootstrap

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

You may also like

1 comment

plenton November 18, 2019 - 11:20 am

It’s nice solution!
How to reset smartwizard inside modal?
After reopen midal, next button in smartwizard not working!

Reply

Leave a Comment

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