Question

get checked values for jsTree - submit with form post

I'm using the jsTree jQuery plugin with the checkbox theme. Does anyone know how to get the selected values with a form post?

Thank you!

 21  47832  21
1 Jan 1970

Solution

 31

In the last version (3.0), the API was changed.

If you need just array of selected IDs (like in examples in this node), it is now very easy:

var selectedElmsIds = $('#tree').jstree("get_selected");

If you need to iterate over the selected elements, you just need to pass additional "true" parameter.

var selectedElmsIds = [];
var selectedElms = $('#tree').jstree("get_selected", true);
$.each(selectedElms, function() {
    selectedElmsIds.push(this.id);
});
2014-03-18

Solution

 18

Have you got your answer ? If not, here is one that appears in the jstree google groups

    function submitMe(){ 
        var checked_ids = []; 
        $("#server_tree").jstree("get_checked",null,true).each 
            (function () { 
                checked_ids.push(this.id); 
            }); 
           doStuff(checked_ids); 

2011-06-10