JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums Accordion getting data element from accordion smart-accordion-item

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #100774
    edwardsmarkf
    Member

    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.

    #100775
    Hristofor
    Member

    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

    #100776
    edwardsmarkf
    Member

    event.target.closest('smart-accordion-item').dataset.labelname   😁
    THANK YOU!
    this is exceptionally useful.  you might consider adding this in the documentation.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.