- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在 select_node
事件上为 jstree 添加元数据。这就是我要添加的方式:
$.ajax({
type : 'GET',
url : '/assessment/getassess',
dataType : 'json',
success : function(jsonData) {
$("#treeViewDiv").jstree({
"themes" : {
"theme" : "classic",
"dots" : true,
"icons" : true,
"url" : "/css/themes/classic/style.css"
},
"json_data" : jsonData,
"plugins" : ["themes", "json_data", "ui", "contextmenu"],
"contextmenu" : {
items : createMenu
}
}).bind("select_node.jstree", function(e, data) {
$(data.rslt.obj).data("jstree").description = "Size: 45units";
});
}
});
最佳答案
我相信您正在使用 $.data()
功能不正确。
您不为$.data()
函数的结果赋值,并让它自动保存。
你要做的是改变这一行,
$(data.rslt.obj).data("jstree").description = "Size: 45units";
对此,
// On the next line, we use "|| {}" because if the data attribute is unassigned, we want to start with a default empty object.
var jstreeData = $(data.rslt.obj).data("jstree") || {};
// assign the property(ies)/value(s) you want.
jstreeData.description = "Size: 45units";
// finally, reassign your modified object back to the data attribute.
$(data.rslt.obj).data("jstree", jstreeData);
如果数据属性由对象组成,您需要:
最后,要修改 data
属性,您需要使用 $.data( key, value )
函数重载。
关于javascript - 如何在 select_node 事件上为 jstree 添加元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15292503/
我有一个 jstree,其中我使用 select_node 事件来切换节点(展开),因此删除了树中的切换箭头,因为它们看起来很难看,而且我不需要它们。 现在我已经添加了要在树中使用的复选框插件,但发现
我创建了一个 select_node 事件。但是当我们选择一个节点时它会触发两次。在这里,您可以看到我在 select_node 事件上设置的更改,该事件触发了两次。 还在 JStree 初始化中我指
我在 JSTree 和 Ajax 方面遇到了一个奇怪的问题。 我通过 Ajax/PHP 请求生成我的树,该请求使用...生成 HTML(带有 UL、LI、A 标签) $.ajax({ url:
我正在尝试找到一种方法,可以在加载动态上下文菜单(右键单击)时抑制 jstree 中的 changed 事件。我知道你可以 suppress the select_node event在上下文菜单中,
我正在使用 jstree 并且 select_node.jstree 不会触发,这是代码 $(document).ready(function () { //$("#MySplitter").spli
我有 jsTree 和一个按钮。 jsTree有select_node函数 .bind("select_node.jstree", function (event, data) { // some
如何在 select_node 事件上为 jstree 添加元数据。这就是我要添加的方式: $.ajax({ type : 'GET', url : '/asse
我有一个 jsTree,当用户点击一个节点时,它会触发 select_node 事件。但是,我还有一个列表,其中包含一些带有 jsTree 中节点 ID 的条目。在这个列表中选择一个条目时,我只需要从
当你打开节点时,没问题。不调用“select_node.jstree”。但是,当您选择一个节点然后关闭其父节点时,jstree 会出于某种奇怪的原因为该父节点触发“select_node.jstree
当我单击网站上的 jsTree 节点时,出现“未捕获类型错误:无法读取未定义的属性‘obj’”。 单击节点后,jsTree 应使用键检索值,将其保存到表单,然后提交表单。这就是我的 JSON 中“at
我是一名优秀的程序员,十分优秀!