PDA

View Full Version : Any Reason why appendChild("<li>test</li>"); will not work like this?



Cyberangel67
9 Oct 2010, 8:15 PM
When using appemdChild in this manner returns an error, yet there is no real reason why this is an issue.

For example


el = Ext.get('myData');
el.appendChild('<li>test</li>');

Doesn't work with a very strange message. Anyway have any clues what is wrong here? Yet if I dump the variable el back to fireBug there is a clear indication I can use appendChild.

Condor
10 Oct 2010, 10:51 PM
appendChild is used to append existing nodes. You want to append new HTML, so you should be using createChild.

Cyberangel67
29 Oct 2010, 6:14 PM
That seems wrong to me, because the docs cleary state that I can pass a string. A string to me is allowing me to do the above to then create and apply the child.

Condor
29 Oct 2010, 11:51 PM
Yes, you can pass a string, but that is interpreted as the id of an existing element.