I have an ASP.NET MVC3 app that features a form with a nested-table input
(Ie on each row I can add a sub-table, with no limit on depth)
To handle this for my MVC app, I’ve created 2 javascript classes(using this term loosely with js:) that mirror my MVC3 model and post the data to an action method. Everything works great…Except that right now the only way that I know how to do this is with jquery $.ajax or $.post — How can I do a postback in javascript?
I have the URL, and the custom JSON data, and want to do a page postback… Any suggestions? I can’t use the normal form submit due to the nested table scenario described above.
Also, I just want to say, that MVC has made this so simple to render! 🙂 For rendering a recursive view did everything without any script required, only on the saving did I need to screw around with json.
Update:I guess another solution would be — can I change the contents of my form data on submit? My method takes a JSON object, is there any way I can stuff that in my request while my form submit is happening normally?
Well, I found that with the MVC3 binding, the table in my form could be normally bound if I named the fields such as Item[0].Children[1].Children[0].FieldA… etc, everything matched up fine without having to convert to javascript objects/json. I changed my code to fix this naming before a form submit, and it binds pretty well without having to do any json calls at all. Less elegant, but I guess it works.