0
我試圖讓jstree只返回我正在重命名的節點的文本。相反,它會返回當前節點名稱以及所有子節點的連接列表。我已經配置了jstree以按需加載。我能做些什麼來限制由重命名的contextmenu返回的文本只有我試圖重命名的節點?非常感激!以下是完整的jstree代碼:JSTree的data.rslt.obj.text()返回一個文本數組而不是來自所需節點的文本
$("#RequirementsTree")
.bind("select_node.jstree", function(event, data) {
if(is_requirement_node(data))
{
var id = data.rslt.obj.attr("id");
if(id != null)
{
$("#RequirementsTree").jstree('close_all')
}
else {
alert("Requirement node select error");
}
}
})
.bind("create.jstree", function(e, data) {
// Ajax call to Server with parent node id and new node text
$.ajax({
type: "POST",
url: '@Url.Content("~/RMS/insertRequirementNode")',
data: {
ParentID : ParentNode,
ChildNodeText : data.rslt.obj.text()
},
success: function(new_data) {
$.jstree._reference($("#RequirementsTree")).refresh(-1);
ParentNode = null;
data = null;
return new_data;
}
});
ParentNode = null;
if (data.rslt.parent == -1) {
alert("Can not create new root directory");
// Rollback/delete the newly created node
$.jstree.rollback(data.rlbk);
return;
}
BranchReqFLag = null;
}).bind("rename.jstree", function(e, data) {
$.ajax({
type: "POST",
url: '@Url.Content("~/RMS/updateRMSHierarchyNode")',
data: {
NodeID: ParentNode,
NodeText: data.rslt.obj.text()
},
success: function() {
ParentNode = null;
data = null;
}
});
}).jstree({
json_data: {
data: RBSTreeModel,
ajax: {
type: "POST",
data: function (n) {
return {
NodeID: n.attr("id").substring(4),
Level: n.attr("name").substring(7)
};
},
url: function (node) {
return "/Audit/GetRequirementsTreeStructure";
},
success: function (new_data) {
return new_data;
}
}
},
contextmenu: {
items: function($node) {
return {
createItem : {
"label" : "Create New Branch",
"action" : function(obj) {
this.create(obj);
BranchReqFlag = "Branch";
ParentNode = obj.attr("id").substring(4);
},
"separator_before" : true
},
renameItem : {
"label" : "Rename Branch",
"action" : function(obj) {
this.rename(obj);
BranchReqFlag = "Branch";
ParentNode = obj.attr("id").substring(4);
},
"separator_before" : true
}
};
}
},
plugins: ["themes", "json_data", "ui", "crrm", "contextmenu"]
});
});
好的,謝謝!感謝您使用Chrome/Firebug更仔細地檢查數據的建議。 – TheDude