The Wayback Machine - https://web.archive.org/web/20200608094812/https://github.com/javve/list.js/issues/663
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contribution: here is example of how to handle clicked event #663

Open
cekvenich opened this issue Aug 31, 2019 · 0 comments
Open

Contribution: here is example of how to handle clicked event #663

cekvenich opened this issue Aug 31, 2019 · 0 comments

Comments

@cekvenich
Copy link

@cekvenich cekvenich commented Aug 31, 2019

// it assumes: valueNames: [ 'name', 'born', {data: ['id']} ]

      var lst = document.getElementById('users')
            lst.addEventListener('click', onClick)
        }//()

        function onClick(el) {
            var selector = 'li'
            var iel = el.target.closest(selector)
            if(!iel) return
            var id = iel.getAttribute('data-id')
            console.log( id )
        }//()

// I hope it helps someone. ps: there is polyfills for closest()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.