I want to trigger a XMLHttpRequest when the selected index change of a
drop down box. What’s the best way to handle this?
I’m sure I could figure out what javascript call link_to_remote is
making and just wire that up to the drop down box, but I’m just
wondering if there is a preferred or built in rails way to do this. Is
there?
I want to trigger a XMLHttpRequest when the selected index change of a
drop down box. What’s the best way to handle this?
I’m sure I could figure out what javascript call link_to_remote is
making and just wire that up to the drop down box, but I’m just
You don’t need to: remote_function will do that for you. The
documentation for it even use a drop down box as its example.
Fred
I just tried it out, very cool, but not what I need. I need the drop
down ochange to post the whole form, and then I need to stick the
results into an html element inside the form.
remote_function is generating an AJAX.Update like this:
new Ajax.Updater(‘tune_in_link_1’,
‘/my_account/tune_in/update_tune_in_link?channel_id=1’,
{asynchronous:true, evalScripts:true, parameters:Form.serialize(this)})
I need an Ajax.Updater like this:
new Ajax.Updater(‘tune_in_link_1’,
‘/my_account/tune_in/update_tune_in_link?channel_id=1’,
{asynchronous:true, evalScripts:true,
parameters:Form.serialize(this.form)})
Note the difference in parameters:Form.serialize. It has to be
this.form, not this. this evaluates to a select box, this.form evaluates
to the form that select box lives on, and I need that is what I need
serialized.
Is this something I have control over with the ajax helpers, or am I
supposed to build the javascript myself?