答案 0 :(得分:0)
这些行在上下文之外是无效的Javascript(它们应该用大括号括起来形成一个对象文字)。这是你问题中解析错误的来源:
onTreeNodeDblClick: function(n) {
treeEditor.editNode = n;
treeEditor.startEdit(n.ui.textNode);
}
onTreeEditComplete: function(treeEditor, o, n) {
//o - oldValue
//n - newValue
}
以下是解决问题的方法。请注意我的评论......一旦修复了第一个错误,你可能会遇到更多错误:
var tree = new Ext.tree.TreePanel({
// The following function won't be defined, you'll have to configure
// a working root to make this example work... And possibly more!
root: this.getChildren(),
height: 300,
loader: new Ext.tree.TreeLoader(),
useArrows: true,
autoScroll: true,
listeners: {
dblclick: onTreeNodeDblClick
}
});
var treeEditor = new Ext.tree.TreeEditor(tree, {}, {
cancelOnEsc: true,
completeOnEnter: true,
selectOnFocus: true,
allowBlank: false,
listeners: {
complete: onTreeEditComplete
}
});
// It seems that the intention of the author was to declare independent
// functions (as opposed to object methods).
function onTreeNodeDblClick(n) {
treeEditor.editNode = n;
treeEditor.startEdit(n.ui.textNode);
}
function onTreeEditComplete(treeEditor, o, n) {
//o - oldValue
//n - newValue
}