开发者

Go to new URL when select_tag changes?

开发者 https://www.devze.com 2023-03-14 10:54 出处:网络
This ought to be very simple in Rails, but I\'m still learning... My code Sort by <%= select_tag :sort, options, :onchange => \"google.com\" %>

This ought to be very simple in Rails, but I'm still learning...

My code

Sort by <%= select_tag :sort, options, :onchange => "google.com" %>

should redirect to a page (google is just being used as a place开发者_如何学Cholder) when the criterion for sorting is changed.

In case it matters, it'll just be going to the same page, but with ?sort=sort type appended.

Thanks!


How about calling a js function through the onchange attribute?

Sort by <%= select_tag :sort, options, :onchange=>'myFunc(this.value)' %>

The js might be something like:

function myFunc(value) {
  window.location = "http://www.mydomain.com/myapp/mycontroller/myaction?sort="+value
}
0

精彩评论

暂无评论...
验证码 换一张
取 消