在尝试动态加载数据时,我似乎陷入了循环。
select_node -calls-> refresh -triggers-> select_node => death-spiral
也许我需要其他事件或其他方法?我的情况是我正在从多个来源收集数据,并且在某些情况下会计算派生值。因此,我正在使用回调函数
$('#theTree').jstree({
'core' : {
'data' : function (node, cb) {
// my code that figures out the data for different node.id values
}
我只用顶层项目填充树,其想法是当用户单击项目时,我们会刷新子树。
$("#theTree").on('select_node.jstree',
function(e, data) {
$('#theTree').jstree(true).refresh_node(data.node.id);
$('#theTree').jstree(true).open_node(data.node.id);
}
);
正如预期的那样,当调用refresh_node()我的回调并返回一些数据时,问题在于这似乎再次触发了select_node事件。
请提出建议!