简体   繁体   中英

Correct way to increase timer for filterrific_observe_field

The filterrific gem has this jquery function to search automatically... but being a near complete newb with JS, I haven't been able to figure out how to edit it to fire less often.

I've tried copying the method (and whole file) over to my local js folder to edit it there, and renamed the class on the input field that seems to be the trigger it, but it seems that would stop it from reloading until I clicked elsewhere...

$.fn.filterrific_observe_field = function(frequency, callback) { frequency = frequency * 1000; // translate to milliseconds ...

https://github.com/jhund/filterrific/blob/d1d533cbbe88007dc10bbc251db01a0756573db9/app/assets/javascripts/filterrific/filterrific-jquery.js

Any tips?

You should change the code here:

$(".filterrific-periodically-observed").filterrific_observe_field(
  0.5, // Change this to 1.0 for 1 second interval.
  Filterrific.submitFilterForm
);

you could then fork the gem on github, make your changes and use that in your project like:

gem 'filterrific', :git => 'https://github.com/yourname/filterrific.git'

or make a local copy of the gem make your changes and do:

gem 'filterrific', :path => '/path/to/filterrific'

both are a bit of a pain to put into production but should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM