Forum: Ruby on Rails :onChange and AJAX forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ab4c5cd5d9cc028fcba7a5eec8e1bf30?d=identicon&s=25 Alain Pilon (alain)
on 2006-06-06 01:55
Hi,

I have this:

<%= form_remote_tag (:update  => "item_type_list", :url  => {:action =>
:list_item_type_for_brand}, :id => "form1") %>

  <div>
    Brand <%= select :current_brand, :id, @all_brands,{},{:onchange =>
"submit()"} %>
    <input type="submit" value="Change" />
  </div>

<%= end_form_tag %>

which returns a list of items.

Its working when I click on the submit button, but when I use the
:onchange to submit the form, the AJAX calls is sent to a new page
insted of the <div> with the  "item_type_list" id.

Any idea?
Ab4c5cd5d9cc028fcba7a5eec8e1bf30?d=identicon&s=25 Alain Pilon (alain)
on 2006-06-06 02:57
Fixed my own problem:

add

:html => {:id  => "test"}

to the form

and

:onchange => "test.onsubmit()"

for the form submition...

Super simple, as always but wasted a lot of time on it...
This topic is locked and can not be replied to.