My view looks like this
<%count=0%>
<%=link_to_function(“add another”, nil, :id => “more_link”) do |
page|
page.insert_html :bottom, ‘phone_numbers’, add_phone_field(count
+=1)
end
%>
add_phone_field is a helper method.I need to increment count on every
click.But my code above does not do that.
Once count gets the value 1 it remains one.
How can I increase the value of count on every click.
My helper method :
def add_phone_field(num)
html=%{
Phone number
}
html<< (fields_for :contact_phones do |ff|
ff.text_field :phone_number,:index=>num
end )
html<<link_to_function(“delete”, “$(‘phone#{num}’).remove()”)
html<<%{
end