Nested Form with Add/Remove Attributes Button

Hi,

I finally, w/paid help, got my nested form working such that the add/
remove attributes button works.

Now I am wondering if it is possible to only have the ‘remove’
attributes button, only show up after the first row of attributes.

For example … my form starts out with its initial row of attributes,
and presently the ‘remove’ button is at the end of this row, I would
prefer that there be no button. Now lets assume I want to add another
row of attributes and so I click on the ‘add attributes’ button and
another row of attributes are added with the ‘remove’ button at the
end of this row. I would like the ‘remove’ button to only show up with
this second row and any subsequent rows of attributes.

I was reading a blog on the ‘link_to_if’, options at this site:

http://groups.google.com/group/rubyonrails-talk/post?hl=en

and I was wondering where I would use this option and how.

My thinking is that I would like to count how many times the ‘add
attribute’ button is activated and then store this in a global
variable that is availabe to the ‘remove’ attributes button such that
is only appears is the count is > 1.

So maybe I could write a method that counts the number of times the
‘add attribute’ button is activated in the helper where the ‘add
attribute’ button is defined?

Any thoughts, suggestions or hopefully encouragement as to how to
solve this issue?

Thanks.

On Thu, Dec 13, 2012 at 6:18 AM, fuzzy [email protected] wrote:

and presently the ‘remove’ button is at the end of this row, I would
and I was wondering where I would use this option and how.
Any thoughts, suggestions or hopefully encouragement as to how to
solve this issue?

I think the best solution for this issue is using css. Look at
http://www.w3schools.com/cssref/sel_firstchild.asp.
You can also create a js solution where you always remove the delete
button
whenever you add/remove a row.

Thanks Jim … I will check that link out.