Avatar

Level 3

I am building a webapp for editing email content, and have a problem when saving content child elements; I can modify the children via ctx in the webapp but, when I save via Storage object, removed children still remain. That is, if I load the following content:

 

<content>
 <child id="1" ... />
 <child id="2" ... />
 <child id="3" ... />
</content>

 

And manipulate ctx in webapp to change order of 1 and 2, and remove 3

 

<content>
 <child id="2" ... />
 <child id="1" ... />
</content>

 

After passing the Storage Object the resulting children on the stored content is 2,1,3

If I change to 3,2 the resulting children on the stored content is 3,2,3

 

So my conclusion are: child elements are inserted or updated in the storage processes - excising ones are not removed. Anyone have a workaround or tips?

 

I am thinking of doing an enabled attribute and set to false for all "excedeing" children but is seems like a very unnecessary step, and making the solution more complicated that needed.

 

For info, my code for manipulating ctx is as follows:

var ids = "2,1".split(",")
delete ctx.content.child
for(var i=0;i<ids.length;i++){
 ctx.content.appendChild(<child id={i} ... />)
}