Smart select items

  1. I put this code in pageInit and it fired twice when close :
    $(’.smart-select’).on(‘smartselect:closed’,function (smartSelect) {
    console.log(smartSelect);

});
2. How do I find what items has been selected?

Thanks

Well, opened fired twice as well
(’.smart-select’).on(‘smartselect:opened’,function (smartSelect) {

Fired twice because you are likely assign event listener twice. Use more strict selector to specify only required select

Thanks. What about
How do I find what items has been selected?

Thanks

$(‘.smart-select select’).on(‘change’, function (e) {
// selected options
$(this).find(‘option:checked’)
})

Sorry, I was not clear. I want to find checked items when click close and ‘smartselect:closed’ function fired.

Thanks.

You can use
$$(document).on(“smartselect:close”, “el_selector”, e => {
//checked options
$(‘.smart-select select option’).forEach((el, index) => {
return $$(el).is(":checked") ? el : ‘’;
})
});