Hey all,
I'm trying to submit the following ajax form using the onchange on a
rails select.
<% form_remote_tag(:url => { :action => :add_facilitator }, :html =>
{:id => 'add_facilitator'}) do %>
<%= select :facilitator, :id, @facilitators.map{|u|
[u.surname,u.id]}, {:include_blank => '', :onchange =>
"'add_facilitator'.onsubmit()"}%>
<% end %>
If I add a submit tag it works perfectly but i'd rather use onchange
instead.
any help is greatly appreciated.
j
Hey all,
I'm trying to submit the following ajax form using the onchange on a
rails select.
<% form_remote_tag(:url => { :action => :add_facilitator }, :html =>
{:id => 'add_facilitator'}) do %>
<%= select :facilitator, :id, @facilitators.map{|u|
[u.surname,u.id]}, {:include_blank => '', :onchange =>
"'add_facilitator'.onsubmit()"}%>
<% end %>
$('add_facilitator').submit()
Fred
HI Fred,
Thanks for the reply.
<form action="/users/add_facilitator" id="add_facilitator"
method="post" onsubmit="new Ajax.Request('/users/add_facilitator',
{asynchronous:true, evalScripts:true,
parameters:Form.serialize(this)}); return false;">
<select id="facilitator_id" name="facilitator[id]"><option
value=""></option>
<option value="1">jj</option></select>
</form>
Hi Fred,
Thanks for the reply, however, even with your code, the following is
the html produced by the helper. There is no onchange in the select
definition.
<form action="/users/add_facilitator" id="add_facilitator"
method="post" onsubmit="new Ajax.Request('/users/add_facilitator',
{asynchronous:true, evalScripts:true,
parameters:Form.serialize(this)}); return false;">
<select id="facilitator_id" name="facilitator[id]">
<option value=""></option>
<option value="1">jj</option>
</select>
</form>
Any ideas?
j
Hey all,
I'm trying to submit the following ajax form using the onchange on a
rails select.
<% form_remote_tag(:url => { :action => :add_facilitator }, :html =>
{:id => 'add_facilitator'}) do %>
<%= select :facilitator, :id, @facilitators.map{|u|
[u.surname,u.id]}, {:include_blank => '', :onchange =>
"'add_facilitator'.onsubmit()"}%>
<% end %>
$('add_facilitator').submit()
oh and you need to make the onchange be in the second options hash, ie
{:include_blank => true}, {:onchange => ...}}
Fred
Did that Fred and it worked.
Thanks for your help.