II’m switching to jQuery and wondering how do I pull the onchange:
stuff out of the following for a select and put it into a handler?
here’s what I have in my view now:
<%= select_tag :selected_email,
options_from_collection_for_select(update_request.contact.emails,
‘id’, ‘value’, update_request.contact.primary_email_id),
:onchange => remote_function(:url => {:action
=> :set_request_email, :id => update_request.id}, :with => “‘value=’ +
value”),
:id => “request_email_#{update_request.id}” %>
I have this in application.js:
jQuery(document).ready(function() {
// handle change events from update_requests listing
$(“select[id^=‘request_email’]”).change(function(event) {
var selected = $("#" + event.target.id + " option:selected");
alert('You chose ' + selected.val());
});
});
but, how would I extract the options/params and post them to
the :set_request_email action from the JS?