accessible_modal_window
accessible_modal_window copied to clipboard
Can't add additional modals dynamically
I'm trying to initialize modals for items added via an infinite scroll script. It isn't working, however, because var modal
isn't accessible globally.
The scoped modal
variable is throughout the script, like in setupModal()
and setupTrigger()
methods. There's no way to modify this important variable.
Ideally, I'd like a way to be able to add modals to the modal
variable, or add a method that would reset modal
, then run init()
again.
Hey @zackkatz, thanks for the issue.
I like the idea, but I'm going to think on this a bit.
I also exposed modal
globally by converting everything to use ARIAmodal.modal
—that allows modification externally. But this was the cleanest PR I could make :-)
Just wanted to check in and let you know I haven't forgotten about this issue, @zackkatz.
Going to try and make sure I give it another look next week. Also want to mention that I've been doing working on refactoring the script in general, and this feature, and a few more, are in the works as part of that refactor too.
Hi, I just wondered if you had been able to look at this issue yet?
I've got a working version having made a few changes.
Main changes are
var allyModal = (function ( w, doc, undefined ) { ... return { init: function() { // Set document at point of init body = document.body; main = doc.getElementsByTagName('main')[0] || body; modal = doc.querySelectorAll('[data-modal]'); children = doc.querySelectorAll('body > *:not([data-modal])'); ARIAmodal.organizeDOM(); ARIAmodal.setupTrigger(); ARIAmodal.setupModal(); ARIAmodal.autoLoad(); } }
})( window, document );
allyModal.init();
This means I can call the allyModal.init() function anywhere and it takes the most uptodate DOM and runs at that point. Needed this so I can run it on html inserted from AJAX.
Let me know if you think there are issues with this approach.
Hey @scottaohara, any updates on this issue? I'd be glad to step in and help!
been working on a big rewrite of the script which will address this issue. So should hopefully have something pushed within the next month or so.