Magento Asked on December 6, 2021
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?
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.
http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/widgets/widget_modal.html#modal_closed
myModal.modal({
innerScroll: true,
modalClass: '_my-box',
buttons: [],
closed: function () {
alert('cleaning up');
}
}).trigger('openModal');
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.
Answered by Langley on December 6, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP