PDA

View Full Version : YAHOO.ext.DomHelper backwards?!



jay@moduscreate.com
1 Dec 2006, 11:40 AM
var TreeDivs = {
tag: 'div',
id: 'TestDiv',
html: 'Parent1',
children: [{
tag: 'div',
id: 'TreeDiv1',
cls: '',
html: 'Child 1',
children: [{
tag: 'div',
id: 'PPTree',
html: 'Child 1 Child'
}]
}]
};
dh.overwrite('centerData', TreeDivs);

Results in


{div id="centerData"}
{div id="TestDiv"}
{div class="" id="TreeDiv1"}
{div id="PPTree"}Child 1 Child{/div}
{/div}
{/div}
{/div}


But in the browser, looks backwards:
Child 1 Child
Child 1
Parent1

what gives?

(substituted < for { ,etc)

jay@moduscreate.com
1 Dec 2006, 11:53 AM
early bump :)

jack.slocum
1 Dec 2006, 11:57 AM
The order of the attributes is not important. Using html and children is not really supported but if you do do it it results in the children being created and then the html being appended. html is the innerHTML for the element, and innerHTML would include children. If you need to maintain the order, try wrapping the text in a span and creating as a child.

jay@moduscreate.com
1 Dec 2006, 12:00 PM
Jew da man :)

the order does matter because the "PPTree" div is a Tree that i need to create. The parent nodes are "under" it w/out the span tags, which makes it strange.

Thanks so much. But it still is backwards. oh well.

jay@moduscreate.com
1 Dec 2006, 12:19 PM
Eh, i *think* i know why this is happening.
it seems that the child is before the text of the html.

but... i look in the code (domhelper.js) and can't support my theory.

jack.slocum
1 Dec 2006, 1:49 PM
In DomHelper it builds the children into a string and appends the String. Then if an html attribute exists, it appends that.