Some way to link external actions?
Closed this issue · 2 comments
dawnerd commented
Say you have a button that is not part of the module but you want it to trigger an action in the module, like opening a modal (where the modal is the module). Would this be something that would be useful to put into Domodule core? Not exactly sure the best way it can be implemented. Maybe something the modules themselves setup like so:
class Test extends Domodule {
constructor(el) {
super(el);
this.bindExternal('data-action-modal', this.open, 'click');
}
}
jgallen23 commented
the way I did it before was to create an OpenModal module for the button and then have another modal Module for the specific modal. In the OpenModal, it discovers new modules when it opens and renders the template.
dawnerd commented
Only "problem" with that is now every instance requires a unique id. Maybe if there's no id we randomly generate one?