문제

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