diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 7 | ||||
-rw-r--r-- | app/views/public_body/_search_ahead.rhtml | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0c8544932..2cdd5ee35 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -365,7 +365,10 @@ class ApplicationController < ActionController::Base def get_search_page_from_params return (params[:page] || "1").to_i end + def perform_search_typeahead(query, model) + @page = get_search_page_from_params + @per_page = 10 query_words = query.split(/ +(?![-+]+)/) if query_words.last.nil? || query_words.last.strip.length < 3 xapian_requests = nil @@ -376,8 +379,8 @@ class ApplicationController < ActionController::Base collapse = 'request_collapse' end options = { - :offset => 0, - :limit => 5, + :offset => (@page - 1) * @per_page, + :limit => @per_page, :sort_by_prefix => nil, :sort_by_ascending => true, :collapse_by_prefix => collapse, diff --git a/app/views/public_body/_search_ahead.rhtml b/app/views/public_body/_search_ahead.rhtml index 484d28256..7ade89b8e 100644 --- a/app/views/public_body/_search_ahead.rhtml +++ b/app/views/public_body/_search_ahead.rhtml @@ -1,4 +1,4 @@ -<p> +<div> <% if !@xapian_requests.nil? %> <% if @xapian_requests.results.size > 0 %> <h3><%= _('Top search results:') %></h3> @@ -13,9 +13,9 @@ <%= render :partial => 'body_listing_single', :locals => { :public_body => result[:model] } %> <% end %> </div> - <%= will_paginate WillPaginate::Collection.new(@page, 10, @xapian_requests.matches_estimated) %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated) %> <% end %> -</p> +</div> |