Topic: RJS: Null value problem

Hello.

I'm trying to get the "Creating Variable Number of Models in One Form"-tutorial on this page to wok, but I have some trubble with RJS. I have looked 10 times and even copy the code from the tutorial, but I don't get it to work.

My code is:

[code=ruby]#agents_controller.rb
  def new
    @agent = Agent.new
    @agent.orders.build
  end
  def add_order
    @order = Order.new
  end



#new.rthml
<%= error_messages_for 'agent' %>

<% form_for :agent, :url => { :action => 'create' } do |f| %>

    <p><label for="agent_costumer"><b>Kundnummer</b></label><br/>
    H

Last edited by Dazen (2007-08-14 09:44:10)

Are you happy now?

Re: RJS: Null value problem

there is no id "add_order_link" to replace the add_order link. add a div around it with the proper id:

#new.rhtml
....
<div id="add_order_link">
<%= render :partial => 'add_order_link', :locals => { :index => @agent.orders.size } %>
</div>

also, i think i have read somehwere, to use page.replace_html rather than page.replace, as the latter somehow chokes in IE6 or 7