I have a form which contains rows like this one. I need to be able to call a method on a controller using ajax/jquery when the user clicks the radio button. The method would change the underlying model, on return it would show a message in the flash on the client.
<tr>
<td><%= radio_button_tag 'primary', feature_photo.id %></td>
<td>
<%= feature_photo.name %>
By: <%= feature_photo.photo_credit %>
</td>
<tr>
You’re looking for observe_field. The rest is as simple as any other rails action (an action in a controller that returns something relevant whether that’s text, javascript, etc).
You also mention jQuery, but it’s not obvious how you’re using it in your app.
observe_fieldwill generate Prototype code, not jQuery. If you’ve got some jQuery you can just write a handler for the radio button, perhaps like so:With more details I might be able to provide more comprehensive help 🙂