¡@

Home 

2014/10/16 ¤W¤È 12:06:19

jquery Programming Glossary: phone_numbers

Unobtrusive dynamic form fields in Rails with jQuery

http://stackoverflow.com/questions/1704142/unobtrusive-dynamic-form-fields-in-rails-with-jquery

nested attributes class Person ActiveRecord Base has_many phone_numbers dependent destroy accepts_nested_attributes_for phone_numbers.. dependent destroy accepts_nested_attributes_for phone_numbers reject_if lambda p p.values.all blank allow_destroy true end.. do f f.text_field name f.text_field email f.fields_for phone_numbers do ph render partial 'phone_number' locals f ph end f.submit..

Unobtrusive dynamic form fields in Rails with jQuery

http://stackoverflow.com/questions/1704142/unobtrusive-dynamic-form-fields-in-rails-with-jquery

github. First set up the models and make sure they support nested attributes class Person ActiveRecord Base has_many phone_numbers dependent destroy accepts_nested_attributes_for phone_numbers reject_if lambda p p.values.all blank allow_destroy true end.. attributes class Person ActiveRecord Base has_many phone_numbers dependent destroy accepts_nested_attributes_for phone_numbers reject_if lambda p p.values.all blank allow_destroy true end class PhoneNumber ActiveRecord Base belongs_to person end Create.. the Person model form_for @person builder LabeledFormBuilder do f f.text_field name f.text_field email f.fields_for phone_numbers do ph render partial 'phone_number' locals f ph end f.submit Save end This will work by creating a set of template fields..