JSTree's data.rslt.obj.text()返回一个文本数组,而不是所需节点的文本
JSTree's data.rslt.obj.text() returns an array of text rather than the text from the desired node
我试图让jstree只返回我正在重命名的节点的文本。相反,它返回当前节点以及所有子节点的名称的串联列表。我已经将jstree配置为按需加载。我该怎么做才能将上下文菜单返回的用于重命名的文本限制为仅限于我试图重命名的节点?非常感谢!以下是完整的jstree代码:
$("#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"]
});
});
data.rslt.new_name
保存输入的新名称。如果您使用Chrome或Firebugs来检查data
,您将找到大多数此类问题的答案。
...
}).bind("rename.jstree", function(e, data) {
$.ajax({
type: "POST",
url: '@Url.Content("~/RMS/updateRMSHierarchyNode")',
data: {
NodeID: ParentNode,
NodeText: data.rslt.new_name
},
success: function() {
ParentNode = null;
data = null;
}
});
})
...
相关文章:
- Javascript,有没有一种方法可以将数组写成没有逗号或空格的单个文本字符串
- 是否有任何方法可以使用jQuery替换在数组中定义值的文本
- 高亮显示与数组字符串一起使用时文本插件中断
- 使用Javascript使用数组检查文本框中的值
- 如何获取文本框组的值,并使用jquery将它们放入(key:Value)数组中
- JavaScript:将字符串数组转换为文本区域
- 如何放置ÅÄ和#214;在javascript数组中,然后将其与html文本进行比较
- 数组中的随机文本字符串
- 单击select'时将数组行回显到文本区域中;s选项
- 数组在手动写入时有效,但从文本文件加载时无效
- I'我试图用javascript制作文本框,并将输入的值发送到数组中的文本框中进行添加
- 对照数组脚本检查文本框中的值不起作用
- 数组函数不适用于从元素文本创建的JavaScript数组
- 如何从DIV数组向DIV添加文本
- 你能提交一个带有文本输入数组的表单吗
- 将文本框数组值传递到javascript中
- 如何将数组文本框名称发送到 ajax
- 将文本文件读入数组
- 使用 jQuery 计算文本框数组中的值
- JavaScript从文本/数组中删除重复项