Hello,
Normally, when I add a child to a DataElement, I get one ondata call for
each DataElement added. However, when I add a DataElement to a parent that
already has one Child (and only one child), two ondata calls are fired. One
for each child. When there are 0, 2, 3... child elements, this does not
occur. Is this a bug or a feature? I was unable to find reference in the bug
tracker.
Below is code illustrating the phenomenon.
Regards,
David
<canvas>
<dataset name='testdata'>
<drawer>
<folder id='a' />
</drawer>
</dataset>
<view>
<simplelayout />
<view>
<simplelayout />
<button>
Add page to folder
<datapointer name='dp' xpath='testdata:/drawer/folder[1]' />
<attribute name='pageid' type='string' value='1' />
<handler name='onclick'>
var page = new lz.DataElement('page', {'id': this['pageid']});
this.dp.p.appendChild(page);
newid = parseInt(this['pageid'])+1
this['pageid'] = newid.toString()
</handler>
</button>
<text>Contents of folder a</text>
<text datapath='testdata:/drawer/folder[1]/page/@id'>
<handler name='ondata'>
Debug.debug('ondata', this.datapath);
</handler>
</text>
</view>
<text>
Please note: every time a node is added, one ondata event occurs EXCEPT when
there is one other child node, in which case two ondata events fire.
</text>
</view>
</canvas>