简体   繁体   中英

How does jQuery on(close,callback) work? Materialize

I tried to replicate an issue I encountered at work that I cannot attach multiple materialize drop-downs to the on close event.(only the first one is working)

So I make a snippet here. materialize multiple dropdown

Quite the opposite, even though I explicitly select the first drop down using get[0] and attach the close event, the callback fires when I close the second non-selected drop-down too.

Seems like only the first dropdown listens to the event. if I put

$(dropDown).on('close', function() {
    console.log(this)
});

This always refers to the same obj. Because of the fact that clicking anywhere other than the dropdown would trigger the event, I thought the second dropdown trigger the close event too. This weird behavior was because I used a older version of materialize, updated the version and the problem is gone.

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