(context) I have information from a group of elements that I collect in a JSON object, which is then passed to the MVC3 controller, where it is deserialized into an object.
There are "elements" and "element settings". Currently, I have both elements and element parameters in a flat JSON object. Ideally, I would like element settings to be nested under each element. Currently my code is as follows:
var editeditems=[];
...
$("#SaveChanges").click(function() {
$(".portlet").each(function() {
var itemname = $(this).data("itemname");
editeditems.push(
{
"itemname": itemname
});
itemname = $(this).data("itemname");
$(".settingInput").each(function() {
editeditems.push(
{
"settingkey":$(this).attr("name"),
"settingvalue":$(this).attr("value")
});
});
});
Under $ (". SettingInput"). Each function adds settings. I tried a syntax like "editItems.settings.push ..", but it returns with a syntax error.
Any help would be greatly appreciated!
source
share