Micromodal
Micromodal copied to clipboard
Modals for dynamic content
We have HTML content that's added to the page dynamically. It would be nice to initialize modals for just this tree of elements. We could initialize the entire document again, but doesn't that add multiple triggers ( triggerMap[targetModal].push(trigger); )?
Would something like this work?
old - var triggers = [].concat(toConsumableArray(document.querySelectorAll('[' + options.openTrigger + ']'))); new - var triggers = [].concat(toConsumableArray(document.querySelectorAll(options.openTriggerQuery)));
Micromodal.init({openTriggerQuery: '#newstuff * [data-micromodal-trigger]'})
or maybe this var triggers = [].concat(toConsumableArray(document.querySelectorAll(options.root + '[' + options.openTrigger + ']'));
Thanks for opening this isssue. As of now this library does not have this feature. Will try and include it in a next release.
Friendly bump reminder <3
Second this bumb
➕1. But thanks for the library - been working well. In the meantime I'm passing this along via a listener which grabs the data attribute of the clicked trigger with the info I need, and then finds the modal and replaces / inserts the content.