Nested Form Model in Rails not saving items added with jQuery -


i'm following ryan bate's railscast (#197) nested model forms.

if submit form has 3 fields added in controller:

3.times { @prof.experiences.build } 

...they save properly. if field, however, added via jquery, isn't saved.

has else had experience sort of problem before?

edit: html generated without jquery:

<div class="fields"> <table> <tbody><tr> <td>position title:</td> <td><input id="applicant_profile_experiences_attributes_0_title" name="applicant_profile[experiences_attributes][0][title]" size="30" type="text"></td> </tr> <tr> <td>employer:</td> <td><input id="applicant_profile_experiences_attributes_0_employer" name="applicant_profile[experiences_attributes][0][employer]" size="30" type="text"></td> </tr> <tr> <td>responsibilities</td> <td><textarea cols="40" id="applicant_profile_experiences_attributes_0_description" name="applicant_profile[experiences_attributes][0][description]" rows="4"></textarea></td> </tr> <tr> <td>start date:</td> <td><select id="experience_from_date_1i" name="experience[from_date(1i)]"> <option value="1970">1970</option> <option value="1971">1971</option> </select> </td> </tr>  </tbody></table> <p><input id="applicant_profile_experiences_attributes_0__destroy" name="applicant_profile[experiences_attributes][0][_destroy]" type="hidden" value="false"><a href="#" onclick="remove_fields(this); return false;">remove</a></p> </div> 

code added jquery:

<div class="fields"> <table>     <tbody><tr>         <td>position title:</td>         <td><input id="applicant_profile_experiences_attributes_1366407307283_title" name="applicant_profile[experiences_attributes][1366407307283][title]" size="30" type="text"></td>     </tr>     <tr>         <td>employer:</td>         <td><input id="applicant_profile_experiences_attributes_1366407307283_employer" name="applicant_profile[experiences_attributes][1366407307283][employer]" size="30" type="text"></td>     </tr>     <tr>         <td>responsibilities</td>         <td><textarea cols="40" id="applicant_profile_experiences_attributes_1366407307283_description" name="applicant_profile[experiences_attributes][1366407307283][description]" rows="4"></textarea></td>     </tr>     <tr>         <td>start date:</td>         <td><select id="experience_from_date_1i" name="experience[from_date(1i)]"> <option value="1970">1970</option> <option value="1971">1971</option> <!-- removed big date list --> </select> </td>     </tr>  </tbody></table> <p><input id="applicant_profile_experiences_attributes_1366407307283__destroy" name="applicant_profile[experiences_attributes][1366407307283][_destroy]" type="hidden" value="false"><a href="#" onclick="remove_fields(this); return false;">remove</a></p> </div> 


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -