jhund / filterrific

Filterrific is a Rails Engine plugin that makes it easy to filter, search, and sort your ActiveRecord lists.
http://filterrific.clearcove.ca
MIT License
910 stars 124 forks source link

Race condition when conducting a search #194

Open Boucherie opened 4 years ago

Boucherie commented 4 years ago

I have a race condition manifesting when a user does a search, quickly conducts their spelling (backspace) and then completes their query. We have been finding that the removal of characters takes longer for the query to complete, and thus the asynchronous return is causing havoc with the user searches. How can I build in a way to abort the fetch or set up the necessary promises in the short index.js.erb snippet?

$("#accounts_filterrific_table").html('<%= j render partial: "/accounts/account_table_row", collection: @accounts %>');