PDA

View Full Version : AppendChild/textchange listener problem



tmcdonald
2 Nov 2011, 12:47 PM
I have inherited some ExtJS code that is causing me problems. It was originally ExtJS 2.2 code, but 3.31 is being used now. The following only happens with internet explorer:

I have a listener for textchange that seems to fire before the text has changed when a new node is added using appendChild. If I comment out the "node.parentNode.reload()" call, the code works. However, the leaf nodes appear as folders until the page is physically reloaded.

Could someone please give me some direction on repairing this?

ListTree.addListener('textchange',
function (node, text, oldText)
{
// Determine if this is a leaf or folder.
if (node.isLeaf())
{
Ext.Ajax.request
({
url: 'update-list.php',
params: { listid: node.id, parentNode: node.parentNode.id, listname: text, type: '1', action: 'updateItem' },
callback: function()
{
node.parentNode.reload();
}
});
}
else
{
Ext.Ajax.request
({
url: 'update-list.php',
params: { folderid: node.id, parentNode: node.parentNode.id, foldername: text, type: '1', action: 'updateFolder' },
callback: function()
{
node.parentNode.reload();
}
});
}
}
);

mitchellsimoens
3 Nov 2011, 8:10 AM
Are you getting any errors? Also, when you post code please wrap in code tags to preserve spacing.

tmcdonald
3 Nov 2011, 9:06 AM
I get a javascript error if I leave the node.parentnode.reload uncommented: this.editNode.ui.focus is null or not an object. (Internet explorer only)

It appears in IE that two nodes get created for a 'folder': a blank entry one and an "orphaned one" which puts the edit box in the top left corner of the browser. For a 'leaf' the results are repeated, but there is default text [ <some number ] i.e. [6]

In Firefox there aren't any issues. Any ideas why a double entry would be created in IE, but not Firefox? Could it be that the child is being appended incorrectly?

Appending:

if (parent.isExpanded())
{
var node = parent.appendChild(
new ListsTree.TreeNode(
{
id:Ext.id(),
allowChildren:true,
draggable:true,
expandable:true,
leaf:false
}));
}



var ListTreeEditor = new Ext.tree.TreeEditor(ListTree, {
allowBlank:false,
cancelOnEsc:true,
completeOnEnter:true,
constrain:true,
ignoreNoChange:true,
});