checkbox的jsTree的一个调用




    
    
    
    
    
    



tree.js的代码
       $(function () {
            $.ajaxSetup({cache:false});
            $("#tree").tree({
                data : {
                    type : "json",
                    async : true,
                    opts : {
                        async : true,
                        method : "GET",
                        //向后台发送请求的url或json格式的数据文件
                        url : "json_data.json"
                    }
                },
                root : { attributes : { "id" : "0" }, data : "ROOT", state : "closed"},
                lang:{
                    loading:"目录加载中……"
                },
                ui:{
                    theme_name:'checkbox'
                },
                callback : {
                    // Make sure static is not used once the tree has loaded for the first time
                    onload : function (t) {
                        t.settings.data.opts.static = false;
                    },
                    beforedata : function (n, t) {
                        if (n == false)
                            t.settings.data.opts.static = t.settings.root;
                        else
                            return {parent_Id : $(n).attr("id") }
                    },
                    //checkbox树展开之后,设置节点为选中状态
                    onopen_all : function() {
                      var selectedIds = [];
                      for (var i = 0; i < selectedIds.length; i++)  {
                       jQuery.tree.plugins.checkbox.check($("#"+ selectedIds[i]+""));
                      }
                    }
                },
                plugins:{
                    checkbox:{}
                }
            });
        });

你可能感兴趣的:(前端)