Is it possible to change <wa-dialog> to not need JS and do not bind to sibling element? #180
HovKlan-DH
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
We've been discussing an API to enable this through a data attribute, like this: <wa-dialog id="about">
About this website
</wa-dialog>
<button data-dialog="open about">
Open
</button> The syntax is <wa-dialog id="about">
About this website
<button data-dialog="close">
Close
</button>
</wa-dialog> This syntax could easily be adapted to other elements that require similar interactions. @HovKlan-DH would such a syntax work for you? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
<wa-dialog>
is for sure is one of these need-to-use features on a web page, so I am trying to see how I can use it.I think I do understand how to implement it, but I also find it a little not-optimal when writing the code for it.
I am using this code from the documentation, though I changed it slightly with an additional button:
Two issues with this:
(1)
To not clutter my code base, then ideally I want to gather all modals/popups elsewhere, as I then have them easy to change one place, but with the current implementation, then it seems to rely on the button to be the next sibling? Would it not be possible to divide this, so I can have all dialogs placed e.g. at bottom of my code base?
(2)
Wouldn't it be possible to handle the Javascript natively from the library? I would of course need to somehow bind the
<wa-dialog>
to the<wa-button>
(or any other HTML element), but it could reduce the complexity if not having to deal with the "open dialog" method in JS.Beta Was this translation helpful? Give feedback.
All reactions