1
我想在用户每次打开节点时强制执行ajax调用,即不缓存。一个小小的Google提示在用户关闭后删除一个节点的子节点。看起来很简单,但我不能让它工作。
在下面的代码中,after_close事件实际上是被触发的,但是三个删除子节点的语句似乎没有效果。我得出这样的结论,因为当节点第一次打开时,我观察到fiddler中的初始ajax调用,但关闭节点并重新打开节点不会生成调用。 备注: 我使用随机数参数来防止在浏览器上缓存。 我已经设置'check_callback'标志每the documentation。从jstree节点清除缓存
// load the tree
$('#tree').jstree({
'core': {
"themes": { "theme": "classic", "dots": false, "icons": false },
'html_titles': true,
'load_open': true,
'data': {
'url': 'GetChildNodes/',
'data': function (node) {
return { 'id': node.id === '#' ? '0_0' : node.id, 'noCache': Math.random() };
}
},
'check_callback': function() { return true; }
},
"plugins": ["themes", "ui"]
});
// Handles tree view links so that the tree view does not intercept the event.
$("#tree").delegate("a", "click", function (e) {
if ($("#tree").jstree("is_leaf", this)) {
document.location.href = this;
}
else {
$("#tree").jstree("toggle_node", this);
}
});
$('#tree').on('after_close.jstree', function (e, data) {
var tree = $('#tree').jstree(true);
var children = tree.get_children_dom(data);
tree.delete_node(children);
});