質問

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.

役に立ちましたか?

解決

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..

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top