Let me try and explain the scenario:
I have a form with multiple items in it. The form is multi-functional so it has multiple submit buttons that are handled on the server correctly.
A single item can be deleted (one submit button per item) and also all items can be saved (a submit button at the bottom of the form).
When an item is deleted a $.post is used and the DIV containing the form is updated with the new response using
$("#containingDIV").html(response)
therefore omitting the deleted item creating a new form.
If I subsequently hit the Save All button and call to
$(form).serialize();
serializes the correct number of items but it includes the item that was deleted and misses the last item in the form.
I can’t get my head around why this is happening but I’m no jQuery guru so hoping someone can shed some light on this.
Any help is much appreciated.
Thanks,
Tom.
Thanks everyone for helping. I’ve just worked out what is going on and it’s to do with ASP.NET MVC framework not jQuery. I inspected the response being returned and noticed that all the inputs contained the same item id’s as they did prior to the delete. a call to ModelState.Clear() solved the problem for me. Arrrgghh! 😀