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=%{<div id="phone#{num}">
<label for="contact_phones_phone_number">Phone number</label>
}
html<< (fields_for :contact_phones do |ff|
ff.text_field :phone_number,:index=>num
end )
html<<link_to_function("delete", "$('phone#{num}').remove()")
html<<%{</div>}
end
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---