Frage

How can we add an onClick attribute to sort_link?

<%= sort_link @search, :created_at, "Created At" %>

I even tried this solution : Rails 3.2 and Ransack - Is it possible to pass additional params in a sort_link? but it didn't work.

What I really need is to add an onClick: "return false;" to make sure the page doesn't scroll to the top every time I click this link.

War es hilfreich?

Lösung

Correct me if I'm wrong, but doesn't Ransack refresh the page (make a request to the server, replace the markup) which would cause the page to scroll to the top?

I don't think this has anything to do with click handlers..

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top