散分,JSTree展开父节点异步加载子节点

sz_syy 2014-09-04 09:19:29
需求:由于jstree要展示大量数据,一次加载速度很慢,所以想在展开父节点在加载子节点。
插件JSTree 3.0
代码:
<script type="text/javascript" src="../script/jstree/dist/libs/jquery.js"></script>
<script type="text/javascript" src="../script/jstree/src/jstree.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#menutree").jstree({
"core": {
"animation": 0,
"check_callback": true,
"themes": { "stripes": true },
"data": {
'url': '../ajax/s_module.ashx?flag=1'
}
}
})
.on('changed.jstree', function (e, data) {

});

});
</script>
以上代码只是一次性加载所有节点,
希望有高手能帮忙实现展开异步加载子节点,感谢!
...全文
291 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackoulee 2014-09-18
  • 打赏
  • 举报
回复
You can also use AJAX to populate the tree with JSON your server returns. The format remains the same as the above, the only difference is that the JSON is not inside the config object, but returned from the server. To take advantage of this option you need to use the $.jstree.defaults.core.data config option. Just use a standard jQuery-like AJAX config and jstree will automatically make an AJAX request populate the tree with the response. In addition to the standard jQuery ajax options here you can supply functions for data and url, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used as URL and data respectively. If you do not return correct json headers from the server, at least set the dataType jQuery AJAX option to "json". $('#tree').jstree({ 'core' : { 'data' : { 'url' : function (node) { return node.id === '#' ? 'ajax_roots.json' : 'ajax_children.json'; }, 'data' : function (node) { return { 'id' : node.id }; } } });
Null_Reference 2014-09-04
  • 打赏
  • 举报
回复
貌似Ztree有异步加载...
  • 打赏
  • 举报
回复
http://www.w3school.com.cn/example/ajax_examples.asp
sz_syy 2014-09-04
  • 打赏
  • 举报
回复
引用 1 楼 Hsuifengershi 的回复:
jq ajax 这几字母含义实在太深,小弟不能领悟!
  • 打赏
  • 举报
回复
jq ajax
  • 打赏
  • 举报
回复

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧