简体   繁体   中英

Waiting to load results until search using filterrific

Does anybody know a way to make filterrific hold results until the user begins a search?

By default, filterrific displays unfiltered, paginated results to the user but I only need results once the user starts to type in the search query field.

Default filterrific gem behavior

Here is a reworked example from the gem documentation. The concept is to return empty array if there is no search params for filterrific.

def index
  @filterrific = initialize_filterrific(
    Student,
    params[:filterrific]
  ) 

  @students = @filterrific.find.page(params[:page]) if params[:filterrific].present?
    @students = [] if params[:filterrific].blank?

  respond_to do |format|
    format.html
    format.js
  end
end

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