我已经看到使用jquery ajax的请求响应进行延迟加载,但是没有任何方法可以使用Socket IO延迟加载节点数据吗?例如我想要这样的东西
$("#tree").jstree({
"core": {
"data": function(data){
socket.on("node",function(node){
data = node;
})
}
}
});
每次单击,我都可以调用数据回调来设置节点。有什么想法吗?谢谢您的期待。
我不知道Socket IO,但是我确定您使用jstree的方法不正确:这是您的函数应为的样子:
function(currentNode, callback){
//we got it called twice, prolly because of angular
if(currentNode.id=='#'){
var me = this;
// perform a request with your framework here and call this once you have your data, '#' mean we're loading the root nodes
var nodes = <your data>
callback.call(me, nodes);
}else{
var me = this;
// we're loading child nodes
// same as before ask the nodes to the server then call the callback with the data loaded.
var nodes = <your data>
callback.call(me, nodes)
}
}
注意:“ this”是树实例。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句