get checked values for jsTree - submit with form post get checked values for jsTree - submit with form post jquery jquery

get checked values for jsTree - submit with form post


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);});


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); 


Everyone, who worked with Jstreeā€™s may face to this question: How to get the checked Ids of Jstree in form submit? here is the solution:

function submitMe() {    var checked_ids = [];    $('#your-tree-id').jstree("get_checked",null,true).each(function(){        checked_ids.push(this.id);    });    //setting to hidden field    document.getElementById('jsfields').value = checked_ids.join(",");}

Now, we set it in a hidden field:

<input type="hidden" name="jsfields" id="jsfields" value="" />