Categories

Friday, November 22, 2024
#919814419350 therichposts@gmail.com
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

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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

1 Comment

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

Leave a Reply

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