简体   繁体   中英

Why is core-select being called twice?

I'm working through my first Polymer example and I've reworked the code to be as follows:

dom = {}
dom.paperTabs = $('paper-tabs')

;(function() {
    $('paper-tabs').on('core-select',coreSelect)
    function coreSelect(myEvent) {
        console.log(dom.paperTabs.prop('selected'))
    }
})()

Q: Why is core-select being called twice? It looks to be doing so in the original as well.

core-select is fired for both selection and deselection. The event.detail.isSelected property tells you which is which.

It's done this way so you can add/remove selection filigree (CSS classes for example) without manual bookkeeping.

The documentation is not clear enough on this point, it trips up a lot of people. We are working on it (either improve the docs or change the API).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM