Ransack: Suggested addition: a "clear" button for a search field, plus "clear all fields" button

Created on 8 Oct 2012  路  5Comments  路  Source: activerecord-hackery/ransack

The title pretty much says it all. It'd be nice to have the possibility of adding a "Clear" button next to each search field that would (a) clear what the user had written in that field, and (b) immediately perform a new search with the changed parameters, that is, subtracting the filtering previously done by the cleared search parameter.

In the same vein, you could have a "Clear all fields" button, to be placed below the search fields, along with the "Search" button. Pressing this button would clear all search fields (surprise!), and perform a new "search" with the changed (empty) parameters -- that is, all the rows of the search space would be shown.

Most helpful comment

It's very easy to add a cancel search link in your page, such as:

<%= link_to "Clear Search", request.path, class:"cancel-button" %>

All 5 comments

This sounds like something that you could implement with a bit of JavaScript inside your application. I don't think it's something that Ransack should inherently support itself.

OK. A nice gem, anyway.

It's very easy to add a cancel search link in your page, such as:

<%= link_to "Clear Search", request.path, class:"cancel-button" %>

@mattconnolly Ha, funny how I'll forget simple tricks like this. Beautiful

<%= link_to "Clear Search", request.path, class:"cancel-button" %> after using Clear Search it will redirecting to main search not staying on current search page can you please give me a sol for that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grillorafael picture grillorafael  路  5Comments

seanfcarroll picture seanfcarroll  路  3Comments

zenati picture zenati  路  4Comments

timoschilling picture timoschilling  路  5Comments

llopez picture llopez  路  4Comments