I have a working function that checks for dirty data in a form and tracks which div container the dirty element is a child of. I am trying to figure out how to store/push the {element.id:element.value} pair into an object where the keys are the div containers mapped to an array of child {element.id : element.value} pairs:
...
var dirtyData = {};
(pseudo) for each element in the form
//isEditableData() returns the div id if we care about the div, else false
var divContainer = isEditableData(element);
if (!divContainer)
continue;
(pseudo) if the element is dirty
cacheDirtyData(dirtyData, divContainer, element.id, element.value);
...
function cacheDirtyData(dataObj, divContainer, elementId, elementValue) {
//I want to do something like...
dataObj["'" + divContainer + "'"][] = {elementId : elementValue};
}
I am doing this assuming the dirtyData object is passed "by reference" and I can just add to it. I know this is not ideal code (no ctor, etc.), but I have a deadline and I'm just trying to get this pig to oink.