开发者

Jstree - precheck checkboxes

I'm using JsTree 1.0 and having trouble pre-checking checkboxes using the checkbox plugin.

Here's my full code:

 $(".tree").bind("loaded.jstree", function (event, data) {
                 $('.tree li.checked').each(function () {
                     $(this).prop("checked", true);
                })
            }).jstree({ 
                "core" : { "animation" : 0}, 
                "json_data" : {
                    "ajax" : {
                        "url" : "/admin/posts/get_taxonomy_tree",
                        "data" : function (n) { 
                            return { id : n.attr ? n.attr("id") : 0 }; 
                        }
                    },
                    "progressive_render" : true
                },
                "checkbox" : {
                    "real_checkboxes" : true,
                    "real_checkboxes_names" : function(n){
                        return [("term_taxonomy_id_" + (n[0].id || Math.ceil(Math.random() * 10000))), 1]; 
                    }
                    },
                "themes" : {
                    "url"   :   "/assets/admin/js/jstree/themes/default/style.css",
                    "icons": false
                },
                "plugins" : [ "themes",开发者_开发问答 "json_data", "checkbox" ]
            }).delegate("a", "click", function (event, data) { event.preventDefault(); });

I've added the bind event for loading.jstree, but this isn't correct - doesn't work.

Any ideas? Thank you!

EDIT:

Solution is to add the class jstree-checked, this will by default pre-check the box


Solution is to add the class 'jstree-checked', this will by default pre-check the box


Make sure to add the "checked" class because it used to pre-check boxes on load =)


The following code may resolve your issue.

$('.tree').jstree("check_all");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜