Marnen Laibow-Koser wrote:
> On Aug 19, 1:07�pm, James West <[email protected]>
> wrote:
> [...]
> 
> Or you could just increment a counter as you create fields, so that
> you have a serial number to put in your id attributes.

> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]


Problem solved

Partial now has this
<%if f.object.new_record? %>
  <%-list_form_id = "list-form-#{uid}"-%>
  <%-edit_form_id = "edit-form-#{uid}"-%>
<%-else-%>
  <%-list_form_id = "list-form-#{f.object_id}"-%>
  <%-edit_form_id = "edit-form-#{f.object_id}"-%>
<%-end-%>

The helper now does this
  def add_address_link(form_builder)
    link_to_function 'New address' do |page|
      form_builder.fields_for :addresses, Address.new, :child_index => 
'NEW_RECORD' do |f|
      html = render(:partial => 'address_form', :locals => { :f => f, 
:uid => 'NEW_RECORD' })
        page << "jQuery('#address_list 
ul').append('#{escape_javascript(html)}'.replace(/NEW_RECORD/g, new 
Date().getTime()))"
      end
    end
  end

So the div ID now matches the child_index which was the ideal solution 
that I set out to achieve and all is good.

3 $$£"!"£$ weeks I've been trying to figure out the best way to deal 
with this and it was so simple in the end.

Huge thanks to ALL that responded it all helped to kick my ideas in the 
right direction.

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to