-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destroying instances #312
Comments
@rctneil Thanks for reporting, we don't have a way of doing this yet. However, that is something we want to solve for our next release. Meanwhile, if you are using the |
Thanks, I did try that after appending items but it didn’t seem to make any difference and didn’t initialise the new modals. |
Noted. Will work on a fix. |
@ghosh , maybe something like this? A part from that everything is literally perfect, great job 🧡 |
@Edodums Yes, something like the refresh mothod. |
I had this same issue. The below is what worked for me.
I have not tested thoroughly, but it has no side effects in my use case. This seems to be enough to flush the MicroModal memory and help a new initialization succeed. @ghosh If the above is at all reckless, let me know. Hope this helps. |
Ran into the need for a My solution was a little different in this case. Since MicroModal checks to be sure that the modal exists, I just remove the modal from the DOM when it's closed. That said, it would be much nicer to have an upstream option to destroy a modal instance and/or make a way to only trigger the open event once. const modalId = 'my-modal';
// remove the modal from the DOM
const modalClose = function() {
const modal = document.getElementById(modalId);
modal.parentNode.removeChild(modal);
}
MicroModal.init({
onClose: modalClose,
}); |
+1 |
Another way to show only once would be to have a variable that you set as false, like modalShown = false, then check if that is false before triggering the modal, then with the onShow event change the variable to true. Next time the modal tries to show, it will check the variable and this time it will fail the condition, so the modal is only shown once. |
I think this is a duplicate of #136 Can anyone confirm? |
Hi,
I've just added this to a local project i'm working on. It's great but I have a grid of items, on which some of them have a Micro Modal set up. These work perfectly but when I use Infinite Scroll to append more grid items to the bottom, Micro Modal does not work on those items which require it that have been appended.
What is the best way of destroying all the Micro Modal instances and recreating them once the new items have been added to the grid?
Thanks,
Neil
The text was updated successfully, but these errors were encountered: