View Full Version : How can i escape html entities when create a tree node ?

22 Apr 2008, 1:04 AM
My code is listed below:

Ext.extend(Ext.tree.MyTreeLoader, Ext.tree.TreeLoader, {
createNode : function(attr) {
attr.text = attr.name;
attr.text = attr.text.replace(new RegExp("<", "gm"), '&lt;');
attr.text = attr.text.replace(new RegExp(">", "gm"), '&gt;');
attr.text = attr.text.replace(new RegExp("&", "gm"), '&amp;');
return Ext.tree.MyTreeLoader.superclass.createNode.call(this, attr);
});if i have a treenode and its text is '<haha>', the node's text turn out to be '&lt;haha&gt;',but if i do not replace those html entities, the text can not be displayed, when i use firebug and inspect the node, i see it's output is '<haha _moz-userdefined=""/>'.
So what should i do to make it display as '<haha>'?

22 Apr 2008, 4:54 PM
anyone can help me ? :((