Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #102199
    Dark Beccio
    Member
    Up
    0
    Down

    Hi,
    Is it possible to make cards in smart-card-view clickable without editing?
    something like
    card.addEventListener(‘click’, () => {
    myFunction();
    });

    #102202
    admin
    Keymaster
    Up
    0
    Down

    Hi Dark Beccio,
    You can achieve that with the following code:

    window.onload = () => {
    const cardview = document.querySelector('smart-card-view');
    const cards = cardview.querySelectorAll('smart-card');
    for(let i = 0; i < cards.length; i++) {
    cards[i].onclick = () => {
    alert("click");
    }
    }
    }

    In the above code we get all smart-card instances inside the card view and add click event handler to them.
    Hope this helps.
    Best regards,
    Peter Stoev
    Smart UI Team
    https://www.htmlelements.com/

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