Forum: Ruby on Rails observer_field - select form

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Achille P. (Guest)
on 2007-06-03 16:26
I want to load a form when a "select form" is changed. I have done this
but it doesn't work( i do not have an error but nothing change when i
change the select list):

in the view:
<code><% form_tag :action => 'update', :id => @cour do %>

<!-- we choose the type of document (which will determine the form to
include) -->
<p><label for="type_article">Choissisez le type de votre
<%= select :cour, :type_article, {"cours"=>"c",
"exercice"=>"ex"},:include_blank=>true %>

<!-- we observe the select list -->
<%= observe_field 'type_article',
          :update => "formulaire",
          :with=>"'type_article=' + escape(value)",

<div id="formulaire">-</div>

<%= submit_tag 'Edit' %>
<% end %></code>

In the controller:
<code>def generation_form
    type_article = params[:type_article]
    if type_article == "ex"
    render :partial => "formex"
    render :partial => "formart"

the partial _formex:
<code>(formualaire exo)
<p><label for="cour_content">Contenu</label><br/>
<%= text_area 'cour', 'content'  %></p></code>

Achille P. (Guest)
on 2007-06-05 15:51
I found my mistake: wrong name of field.
=> <%= observe_field 'cour_type_article', instead of <%= observe_field

But I still have two problems with the result:
-The form is updated when the mouse is over a type of document and would
like to updated it when the user clic on the field.
-Without AJAX in "edit mode" the field were filled by the data already
saved. Now the fields are blank when the form is updated by AJAX.

This topic is locked and can not be replied to.