codevise / activeadmin-searchable_select

Searchable select boxes for forms and filters
Other
97 stars 33 forks source link

Debounce (quietMillis) support #10

Closed johnmaxwell closed 5 years ago

johnmaxwell commented 5 years ago

First of all, thank you for working on this project. This really helped dig us out of a hole of having ActiveAdmin select inputs that were waaaaayyy too long.

I'm looking for an option to debounce my searchable selects inputs to keep from pounding the search endpoints on every keystroke.

select2 already has an option called "quietMillis" nested under the "ajax" family of options. It's a debounce timeout.

Is there a way that this could be accomplished with activeadmin-searchable_select?

tf commented 5 years ago

Hi John,

Select 2 claims that it is possible to set nested options via data attributes. I could not find any reference to a quietMillis option. But there appears to be a delay option to rate limit requests. I haven't tried it myself, but adding a data-ajax--delay attribute to the input might work.

If you can make it work that way, I'd be happy to accept a PR that adds a short example to the README demonstrating how to pass options to Select2.

If it doesn't work, just let me know and we'll figure out something else.

johnmaxwell commented 5 years ago

Thanks @tf ! That's a huge help. That does exactly what I need.

WRT "quietMillis": unfortunately I think I was looking at old documentation.

Looooong commented 4 years ago

I think that we should have a global defaults for select2 options, so that I don't have to add data-ajax--delay to every searchable_select inputs.