hello – it appears as if using accordion is going to meet our needs perfectly if i can get past this issue.
i need to be able to access data from the smart-accordion-item when an item is clicked: https://codepen.io/edwardsmarkf/pen/XWXreve?editors=1111
or perhaps there is there a better way to do this?
using this.parentElement and this.parentNode does not appear to work for me.
our smart element will contain thousands of accordion items, each with up to ten clickable items. we need to keep the html as small as possible.
Hi edwardsmarkf,
You can get the AccordionItem instance using the Element.closest() method, like so: event.target.closest('smart-accordion-item'). Another approach is to use Event.composedPath() which will return all parents of the current target (including the AccordionItem).
Best Regards,
Christopher
Smart HTML Elements Team https://www.htmlelements.com
event.target.closest('smart-accordion-item').dataset.labelname 😁
THANK YOU!
this is exceptionally useful. you might consider adding this in the documentation.