BsMultiSelect: The change event is not firing

First of all, thanks a lot for this plugin!

I am trying to listen for the change event. Here is what I have done

// drilldown.js
const modelsMenu = document.querySelector('.drilldown-models-menu');

if(modelsMenu != null) {
    modelsMenu.addEventListener('change', e => {
        console.log('change was fired');
    });
}

// this works!
window.addEventListener("load", function () {
    var event = new Event('change');
    modelsMenu .dispatchEvent(event);
});
// activator.js
$(function () {
    // is there no way to this plugin without jQuery?
    $('.content-picker').each((_i, item) => {
        var menu = $(item);
        menu.bsMultiSelect({
            placeholder: menu.attr('placeholder') || ''
        });
    });

});

But for some reason the change event isn’t firing. When I manually dispatch the change event on load, it works. But when I select an item from the content-picker menu the change event does not fire. Am I doing something wrong here?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

I guess it works with bs5 not 4. Here is a snippet where it does not work https://codepen.io/crestapps/pen/eYRPodN