Hey all, I'm trying to update a div everytime the value of my drop down box is changed: <tr> <th width="25%"><label for="ci_citype" >Type</label></th> <td width="25%"> <%= select("ci", "citype", CiType.find(:all).collect{|p| [ p.name,p.id]})%> </td> </tr>
<div id="create_ci_container"> <%= render :partial=>'cipart/create_hardware_cis' %> </div>
<%= observe_field("ci_citype", :update => "create_ci_container", :url => { :controller => :create_ci, :action => :create_ci }, :method => "post", :with => "'citype_id='+value") %>
The above code is written in view create_ui.rhtml of ci_controller.
The content in create_ci_controller:
class CreateCiController < ApplicationController layout nil def create_ci @ci_type_id = @params["citype_id"] end end
The content in create_ci.rhtml is:
<% if @ci_type_id == '2' %> <%= render :partial=>'cipart/create_software_cis' %> <% else %> <%= render :partial=>'cipart/create_document_cis' %> <% end %>
When I first load the page it renders cipart/create_hardware_cis in the div create_ci_container. The problem is when I change the value of the drop down box, the corresponding partial file is displayed and then the entire page disappeared immediately.
Please help me to solve this.
Regards Suneeta