And in Rails 3 with CoffeeScript using unobtrusive JavaScript (UJS):
Add to assets/javascripts/my_controller.js.coffee
:
$ ->
$('#field_name').click ->
window.location.href = 'new_url'
which reads: when the document.ready event has fired, add an onclick
event to a DOM object whose ID is field_name
which executes the javascript window.location.href='new_url';