I have created a modal with some dynamic content (input fields) and a save button to save input field data in database and I'm opening that modal on a button click.

Now when I fill all the input fields and save it or when I close the modal by pressing the "X" icon at top right without saving, the data in the modal persists and doesn't get cleared when I reopen that modal using button click.

Is there a way to completely destroy that modal and create a fresh one on each button click?

  • share your modal open js or jquery code and your form as well Dec 10, 2016 at 6:33

1 Answer 1


I dont think there is any destroy method in modal.js. If you want to clear input, reload the modal or whatever you want to do, you can implement closed event and do your thing when the modal is closing.


                    innerScroll: true,
                    modalClass: '_my-box',
                    buttons: [],
                    closed: function () {
                        alert('cleaning up');

The modals are based on Ui widget and that should implement _destroy() method that could also help you if the above doesnt work for any reason.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.