问题描述
我不是在谈论 $(#demo1)。jstree(rename,node)
这使得节点可以为用户编辑。我在谈论代码中正在更改的名称。例如,在我调用 $(#demo1)之前,我的节点都以2位数字[01]作为前缀.jstree(rename,node)
我想删除前缀,并在用户完成编辑后将其重新放入。我已经尝试选择#nodeid a,但在超链接中有一个ins标签,如果我替换URL内容,这将被替换。文档没有帮助,我没有看到图书馆代码的运气,可以帮助我吗? Chris
I am not talking about $("#demo1").jstree("rename",node)
which makes the node editable for the user. I am talking about the name being changed within the code. For example my nodes are all prefixed with a 2 digit number "[01]" so before I call $("#demo1").jstree("rename",node)
I want to strip out the prefix, and put it back in once the user has finished editing. I have tried selecting "#nodeid a" but inside the hyperlink there is an ins tag and this gets replaced if i replace the URL contents. The documentation hasn't been helpful and I havent had much luck looking through the libraries code, can any help me? Chris
推荐答案
推荐方法是使用
The recommended method is to use rename_node
$("#demo1").jstree('rename_node', node , text );
$('#demo1').jstree({
'core': {
'check_callback': true,
/// rest of the options...
}
});
重命名您的节点(替代方案,不推荐)
$("#demo1").jstree('set_text', node , text );
调试
如果您仍然遇到问题,可以使用此方法获取上一个错误。
If you still encounter trouble, you can use this method to get the last error.
$('#demo1').jstree(true).last_error()
旧版本(v1。*)
$("#demo1").jstree('rename_node', [node , text] );
$("#demo1").jstree('set_text', [node , text] );
参见:
- ,用于比较和两种方法的示例。
- (如何调用API方法)
- this jsfiddle for the comparison and example of both methods.
- Interaction with jsTree (how to call API methods)
- API documentation of
rename_node
- API documentation of
set_text
这篇关于如何重命名jsTree节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!