wolffe / tail.select.js

Create beautiful, functional and extensive (multi)select fields with pure, vanilla JavaScript.
https://getbutterfly.com/tail-select/
MIT License
114 stars 17 forks source link

How to avoid the loop when removing all options #22

Open em-piguet opened 1 year ago

em-piguet commented 1 year ago

I'm using the select to fetch some data for a calendar (fullcalendar.js) like this

var select_categories = tail.select(".select-categories", {
        search: true,
        multiSelectAll: true,
        locale: 'fr',
 });
select_categories.on("change", function(){
        calendar.refetchEvents();
}

the select has 19 options and it works great, but when i clic on "All" or "Remove all" the calendar.refetchEvents() event is called 19 times making 19 ajax requests which make the calendar very slow. In this situation how can i do to make only one request ?

wolffe commented 1 year ago

Can you cache the result of the refetchEvents()? I don't know how exactly it's working.

Also, if you think this is a tail.select issue, feel free to submit a PR.