Micromodal icon indicating copy to clipboard operation
Micromodal copied to clipboard

Modals for dynamic content

Open openbrian opened this issue 7 years ago • 6 comments

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 + ']'));

openbrian avatar Nov 09 '18 16:11 openbrian

Thanks for opening this isssue. As of now this library does not have this feature. Will try and include it in a next release.

ghosh avatar Jul 21 '19 12:07 ghosh

Friendly bump reminder <3

masudhossain avatar Jan 23 '20 03:01 masudhossain

Second this bumb

mrpaulphan avatar Apr 12 '21 19:04 mrpaulphan

➕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.

heaversm avatar Dec 30 '21 22:12 heaversm