lcdsantos / jQuery-Selectric

jQuery plugin for easy manipulation and customization of HTML selects
http://selectric.js.org/
MIT License
727 stars 157 forks source link

selectric-change event not fired on mobile #219

Open kobelobster opened 6 years ago

kobelobster commented 6 years ago

Hello,

my config looks like this

$('select.filter-select');
   .selectric({
       disableOnMobile: false,
       onInit: () => {
           $('.filter-box__content').removeClass('blurred');
           // TODO - If is mobile remove first option from selects
       },
       onBeforeOpen: () => {
           const items = $('.selectric-items li');
           items.removeClass('selected');
           items.removeClass('highlighted');
       },
       onOpen: () => {
           const items = $('.selectric-items li');
           items.removeClass('selected');
           items.removeClass('highlighted');
       },
       labelBuilder: (curItem) => {
           const outerSelect = $(curItem.element[0].parentElement);
           return outerSelect.data('filter');
       }
   .on('selectric-change', (event, element, selectric) => {
       $('.mapudo-indicator').show();
       window.location.href = selectric.items[selectric.state.selectedIdx].value;
   });

When I now open my page on mobile, open a select box and select an entry I would hope that the selectric-change event is fired, but in fact it is not.

If I use nativeOnMobile: false it is fired, however, I would like for the user to have the default select box behavior on mobile. Do I need to manually bind an change event on the select boxes as well for mobile to work? Is this the expected behavior?

xserber commented 6 years ago

I manually tied the event. Note the use of