views:

18

answers:

1

I have a jstree with checkboxes that shows up just fine. I can open and close the nodes, check and uncheck the checkboxes, etc.

The problem comes in when I try to get all the nodes that have been checked. Below I list all the ways I have tried, along with the error messages I get when I try each one.

$.tree.plugin.checkbox.get_checked($.tree.reference("#smuDomains"));
$.tree is undefined

$.jstree.plugin.checkbox.get_checked($.jstree.reference("#smuDomains"));
$.jstree.plugin.checkbox is undefined

$.tree.plugins.checkbox.get_checked($.tree.reference("#smuDomains"));
$.tree is undefined

$.jstree.plugins.checkbox.get_checked($.jstree.reference("#smuDomains"));
$.jstree.plugins is undefined

The second one ($.jstree.plugin.checkbox) seems to be getting the closest to working, but it doesn't seem to like the "checkbox" reference. Should it be check_box or something different?

This is the code I use to init the tree:

$.jstree._themes = "../script/css/jstree/themes/";
$("#smuDomains").jstree({
    core : {}, 
    themes : {
        theme : "classic",
        dots : true,
        icons : true, 
        url : false
    },  
    json_data : {
        ajax : {
            url : "[the url]",
            datatype : "json",
            data : function(n) {
                return { id : n.attr ? n.attr("id") : 0 };
            },
            plugins : [ "themes", "json_data", "ui", "checkbox"]
        }); 
    });
A: 

one of the issues with get_checked is that it will stop at parent nodes that are checked.

We ended up going with something like this:

$('#idOfDivContainingTree .jstree-checked')

There is a risk of this not working with future versions of jsTree as it is dependent on the implementation

Dennis Burton