diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-10-30 15:06:17 +0000 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-11-11 16:02:19 +0000 |
commit | c7b4ff24eae6c50cc43799f54df4caed5efa25f0 (patch) | |
tree | e7337c40ed0b0f27f17055fe33d486a91aa96b41 | |
parent | a9853bf1a41623df1b84656ce8dac6f01231f2cd (diff) |
Limit typeahead similar requests on /new/:body
Only return 3 similar requests to prevent the suggestions swamping the
page
-rw-r--r-- | app/views/request/new.html.erb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb index 5ea64aa30..4840b5064 100644 --- a/app/views/request/new.html.erb +++ b/app/views/request/new.html.erb @@ -4,7 +4,9 @@ // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: // http://benalman.com/projects/jquery-throttle-debounce-plugin/ $("#typeahead_search").keypress($.debounce( 300, function() { - $("#typeahead_response").load("<%= search_ahead_url %>?q="+encodeURI(this.value)+"&requested_from=<%= @info_request.public_body.url_name %>", function() { + $("#typeahead_response").load("<%= search_ahead_url %>?q="+encodeURI(this.value)+ + "&requested_from=<%= @info_request.public_body.url_name %>"+ + "&per_page=3", function() { // When following links in typeahead results, open new tab/window $("#typeahead_response a").attr("target","_blank"); |