elasticsearch - How to clear the search results in a Rails app? -


i'm rails noob, , looking assistance in clearing results of search.

i've built sample application lists cafes, , have implemented searching using elasticsearch , searchkick. search function appends parameters url in http://localhost:3000/cafes?search=sydney&commit=search , working correctly.

now i'd add button clear search results:

enter image description here

the clear button's link cafes_path (http://localhost:3000/cafes), reloads page without search parameters:

= form_tag cafes_path, :method => :get       = text_field_tag :search       = submit_tag value = "search"       = link_to cafes_path 
  1. is acceptable way clear search?
  2. is acceptable rails approach use javascript logic enable/disable clear button, based on what's in search box?

please let me know if need see more of model or controller code make sense of question.

  1. this way pretty standard
  2. sure, use javascript - or can google other ways it's been done , see did.

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -