Hi there,
Having a bit of a hairy issue when submitting data over a jquery ajax call. Basically, form values of form fields which have been dynamically added to the screen into a tubular grid using jquery are not updating on a batch save command.
Basically I have a grid listing which displays all current rows saved to the database with each column containing form fields. I then have a form at the top of the page, which is your typical add another detail form. You type your values, press "add" this is saved to the database via a jquery json ajax call, and your form data is added and reflected in a new row in the listings table. (this part works)
My problem lies with when you wish to change the form values within the newly added jquery table row. When the save button is pressed, only any of the already built table row's will be re-saved. Your dynamic row form data does not save. The update call uses jquery ajax and ASP.NET MVC model binding. On the "add" I am returning an asp.net mvc "partial view" to my jquery ajax response and it is being added to a grid listing table using $("#tablename tr:last").after(result)
.
What I have deduced already is, as said, the new dynamically added row does not update. I have an IList<Item>
set returned in my MVC model binding list to my controller action method which contains the entire list of items, minus the newly created jquery dynamic-added form field rows. This is the problem and why when you perform a page refresh, the rows are back to the original form values entered on initial add.
Any ideas why my IList<Item>
's would not include these dynamically added rows? Inspecting in Firebug they use the same naming convent in their name attribute and all should be fine.
Graham.
Update 1 May 11:00 GMT+10: I do receive the values when changing the Model Binding from IList to FormCollection. I do not want to have to use FormCollection rather than model binding, but it begs the question if I can get it correctly through FormCol, why not IList model binder? I have compared the array entry to a working item, and they all fit the same criteria and values.