Geting all the selected nodes in jstree on check event?












15















I'm using get_bottom_selected to get all the checked/selected nodes in JSTree. When I setup a button in my form that calls the following method it works. When I try to call the same function from check box click event it does not find any selected nodes, even if there are some.



function testit() {
var data = $('#my_tree').jstree(true).get_bottom_selected(true);
for(var count = 0; count < data.length; count++){
// Do Stuff
}
}


When the following event fires I want to call the function and get all the selected child nodes, but it does not work. Is there something specific to do on this event that works different than calling from a button click event?



.on("check_node.jstree uncheck_node.jstree", function(e, data) {
testit(); // first line of this function does not get any selected data, even if several are selected. When called from a button click event in my form it does work.
});


Here's how I currently have my jstree setup.



$('#my_tree')
.on("changed.jstree", function (e, data) {
// Do Stuff
})
.jstree({
checkbox: {
"keep_selected_style": false,
"visible" : true,
"three_state": true,
"whole_node" : true,
},
plugins: ['checkbox'],
'core' : {
'multiple' : true,
'data' : {
"url" : "/static/content_data.json",
"dataType" : "json"
}
}
})
.on("check_node.jstree uncheck_node.jstree", function(e, data) {
testit();
});









share|improve this question



























    15















    I'm using get_bottom_selected to get all the checked/selected nodes in JSTree. When I setup a button in my form that calls the following method it works. When I try to call the same function from check box click event it does not find any selected nodes, even if there are some.



    function testit() {
    var data = $('#my_tree').jstree(true).get_bottom_selected(true);
    for(var count = 0; count < data.length; count++){
    // Do Stuff
    }
    }


    When the following event fires I want to call the function and get all the selected child nodes, but it does not work. Is there something specific to do on this event that works different than calling from a button click event?



    .on("check_node.jstree uncheck_node.jstree", function(e, data) {
    testit(); // first line of this function does not get any selected data, even if several are selected. When called from a button click event in my form it does work.
    });


    Here's how I currently have my jstree setup.



    $('#my_tree')
    .on("changed.jstree", function (e, data) {
    // Do Stuff
    })
    .jstree({
    checkbox: {
    "keep_selected_style": false,
    "visible" : true,
    "three_state": true,
    "whole_node" : true,
    },
    plugins: ['checkbox'],
    'core' : {
    'multiple' : true,
    'data' : {
    "url" : "/static/content_data.json",
    "dataType" : "json"
    }
    }
    })
    .on("check_node.jstree uncheck_node.jstree", function(e, data) {
    testit();
    });









    share|improve this question

























      15












      15








      15


      1






      I'm using get_bottom_selected to get all the checked/selected nodes in JSTree. When I setup a button in my form that calls the following method it works. When I try to call the same function from check box click event it does not find any selected nodes, even if there are some.



      function testit() {
      var data = $('#my_tree').jstree(true).get_bottom_selected(true);
      for(var count = 0; count < data.length; count++){
      // Do Stuff
      }
      }


      When the following event fires I want to call the function and get all the selected child nodes, but it does not work. Is there something specific to do on this event that works different than calling from a button click event?



      .on("check_node.jstree uncheck_node.jstree", function(e, data) {
      testit(); // first line of this function does not get any selected data, even if several are selected. When called from a button click event in my form it does work.
      });


      Here's how I currently have my jstree setup.



      $('#my_tree')
      .on("changed.jstree", function (e, data) {
      // Do Stuff
      })
      .jstree({
      checkbox: {
      "keep_selected_style": false,
      "visible" : true,
      "three_state": true,
      "whole_node" : true,
      },
      plugins: ['checkbox'],
      'core' : {
      'multiple' : true,
      'data' : {
      "url" : "/static/content_data.json",
      "dataType" : "json"
      }
      }
      })
      .on("check_node.jstree uncheck_node.jstree", function(e, data) {
      testit();
      });









      share|improve this question














      I'm using get_bottom_selected to get all the checked/selected nodes in JSTree. When I setup a button in my form that calls the following method it works. When I try to call the same function from check box click event it does not find any selected nodes, even if there are some.



      function testit() {
      var data = $('#my_tree').jstree(true).get_bottom_selected(true);
      for(var count = 0; count < data.length; count++){
      // Do Stuff
      }
      }


      When the following event fires I want to call the function and get all the selected child nodes, but it does not work. Is there something specific to do on this event that works different than calling from a button click event?



      .on("check_node.jstree uncheck_node.jstree", function(e, data) {
      testit(); // first line of this function does not get any selected data, even if several are selected. When called from a button click event in my form it does work.
      });


      Here's how I currently have my jstree setup.



      $('#my_tree')
      .on("changed.jstree", function (e, data) {
      // Do Stuff
      })
      .jstree({
      checkbox: {
      "keep_selected_style": false,
      "visible" : true,
      "three_state": true,
      "whole_node" : true,
      },
      plugins: ['checkbox'],
      'core' : {
      'multiple' : true,
      'data' : {
      "url" : "/static/content_data.json",
      "dataType" : "json"
      }
      }
      })
      .on("check_node.jstree uncheck_node.jstree", function(e, data) {
      testit();
      });






      javascript html jstree






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 19 '18 at 16:05









      user1904898user1904898

      84112




      84112
























          2 Answers
          2






          active

          oldest

          votes


















          7





          +100









          Because of the strict mode you will get the exception that if you try to use get_bottom_checked



          TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
          at Function.invokeGetter (<anonymous>:2:14)



          You can use data.selected from your check or uncheck event handler if you just want the ids of selected nodes but if you need more than that you can use 'data.instance._model.data'. As you can see in my example I am trying to alert if there is only one item selected and that's state is open. In the code example, you can see the Alert if you open the `Europe1 and select the checkbox.






          var data1 = [{
          "id": "W",
          "text": "World",
          "state": {
          "opened": true
          },
          "children": [{
          "text": "Asia"
          },
          {
          "text": "Africa"
          },
          {
          "text": "Europe",
          "state": {
          "opened": false
          },
          "children": ["France", "Germany", "UK"]
          }
          ]
          }];

          function testit(data) {
          alert(data.length + ' and ids are ' +data );
          for (var count = 0; count < data.length; count++) {

          }

          }
          $('#Tree').jstree({
          core: {
          data: data1,
          check_callback: false
          },
          checkbox: {
          three_state: false, // to avoid that fact that checking a node also check others
          whole_node: false, // to avoid checking the box just clicking the node
          tie_selection: false // for checking without selecting and selecting without checking
          },
          plugins: ['checkbox']
          })
          $('#Tree').on("check_node.jstree uncheck_node.jstree", function(e, data) {
          if (data.selected.length === 1) { alert(data.instance._model.data[data.selected].state['opened']); }
          testit(data.selected);
          });

          <link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
          <div id="Tree"></div>








          share|improve this answer
























          • Thanks. This got me very close to what I need. Is there a way to get the children from the selected parent? When I click a parent, all the children are selected, but in this example the selected is just the parent. Ultimately I just need all the checked children. Something like this: $('#mytree').jstree(true).get_bottom_selected(true); - Can i get this information from data.instance._model.data[data.selected] ?

            – user1904898
            Jan 3 at 16:15













          • When I click a parent, all the children are selected, but in this example the selected is just the parent. because I am passing three_state: false, // to avoid that fact that checking a node also check others

            – Narendra
            Jan 4 at 1:56



















          2














          According to this
          you can get all selected nodes on change event like this:



              $('#jstree').on('changed.jstree', function (e, data) {
          var i, j, r = ;
          for(i = 0, j = data.selected.length; i < j; i++) {
          r.push(data.instance.get_node(data.selected[i]).text);
          }
          $('#event_result').html('Selected: ' + r.join(', '));
          }).jstree();





          share|improve this answer


























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53855021%2fgeting-all-the-selected-nodes-in-jstree-on-check-event%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            7





            +100









            Because of the strict mode you will get the exception that if you try to use get_bottom_checked



            TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
            at Function.invokeGetter (<anonymous>:2:14)



            You can use data.selected from your check or uncheck event handler if you just want the ids of selected nodes but if you need more than that you can use 'data.instance._model.data'. As you can see in my example I am trying to alert if there is only one item selected and that's state is open. In the code example, you can see the Alert if you open the `Europe1 and select the checkbox.






            var data1 = [{
            "id": "W",
            "text": "World",
            "state": {
            "opened": true
            },
            "children": [{
            "text": "Asia"
            },
            {
            "text": "Africa"
            },
            {
            "text": "Europe",
            "state": {
            "opened": false
            },
            "children": ["France", "Germany", "UK"]
            }
            ]
            }];

            function testit(data) {
            alert(data.length + ' and ids are ' +data );
            for (var count = 0; count < data.length; count++) {

            }

            }
            $('#Tree').jstree({
            core: {
            data: data1,
            check_callback: false
            },
            checkbox: {
            three_state: false, // to avoid that fact that checking a node also check others
            whole_node: false, // to avoid checking the box just clicking the node
            tie_selection: false // for checking without selecting and selecting without checking
            },
            plugins: ['checkbox']
            })
            $('#Tree').on("check_node.jstree uncheck_node.jstree", function(e, data) {
            if (data.selected.length === 1) { alert(data.instance._model.data[data.selected].state['opened']); }
            testit(data.selected);
            });

            <link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
            <div id="Tree"></div>








            share|improve this answer
























            • Thanks. This got me very close to what I need. Is there a way to get the children from the selected parent? When I click a parent, all the children are selected, but in this example the selected is just the parent. Ultimately I just need all the checked children. Something like this: $('#mytree').jstree(true).get_bottom_selected(true); - Can i get this information from data.instance._model.data[data.selected] ?

              – user1904898
              Jan 3 at 16:15













            • When I click a parent, all the children are selected, but in this example the selected is just the parent. because I am passing three_state: false, // to avoid that fact that checking a node also check others

              – Narendra
              Jan 4 at 1:56
















            7





            +100









            Because of the strict mode you will get the exception that if you try to use get_bottom_checked



            TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
            at Function.invokeGetter (<anonymous>:2:14)



            You can use data.selected from your check or uncheck event handler if you just want the ids of selected nodes but if you need more than that you can use 'data.instance._model.data'. As you can see in my example I am trying to alert if there is only one item selected and that's state is open. In the code example, you can see the Alert if you open the `Europe1 and select the checkbox.






            var data1 = [{
            "id": "W",
            "text": "World",
            "state": {
            "opened": true
            },
            "children": [{
            "text": "Asia"
            },
            {
            "text": "Africa"
            },
            {
            "text": "Europe",
            "state": {
            "opened": false
            },
            "children": ["France", "Germany", "UK"]
            }
            ]
            }];

            function testit(data) {
            alert(data.length + ' and ids are ' +data );
            for (var count = 0; count < data.length; count++) {

            }

            }
            $('#Tree').jstree({
            core: {
            data: data1,
            check_callback: false
            },
            checkbox: {
            three_state: false, // to avoid that fact that checking a node also check others
            whole_node: false, // to avoid checking the box just clicking the node
            tie_selection: false // for checking without selecting and selecting without checking
            },
            plugins: ['checkbox']
            })
            $('#Tree').on("check_node.jstree uncheck_node.jstree", function(e, data) {
            if (data.selected.length === 1) { alert(data.instance._model.data[data.selected].state['opened']); }
            testit(data.selected);
            });

            <link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
            <div id="Tree"></div>








            share|improve this answer
























            • Thanks. This got me very close to what I need. Is there a way to get the children from the selected parent? When I click a parent, all the children are selected, but in this example the selected is just the parent. Ultimately I just need all the checked children. Something like this: $('#mytree').jstree(true).get_bottom_selected(true); - Can i get this information from data.instance._model.data[data.selected] ?

              – user1904898
              Jan 3 at 16:15













            • When I click a parent, all the children are selected, but in this example the selected is just the parent. because I am passing three_state: false, // to avoid that fact that checking a node also check others

              – Narendra
              Jan 4 at 1:56














            7





            +100







            7





            +100



            7




            +100





            Because of the strict mode you will get the exception that if you try to use get_bottom_checked



            TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
            at Function.invokeGetter (<anonymous>:2:14)



            You can use data.selected from your check or uncheck event handler if you just want the ids of selected nodes but if you need more than that you can use 'data.instance._model.data'. As you can see in my example I am trying to alert if there is only one item selected and that's state is open. In the code example, you can see the Alert if you open the `Europe1 and select the checkbox.






            var data1 = [{
            "id": "W",
            "text": "World",
            "state": {
            "opened": true
            },
            "children": [{
            "text": "Asia"
            },
            {
            "text": "Africa"
            },
            {
            "text": "Europe",
            "state": {
            "opened": false
            },
            "children": ["France", "Germany", "UK"]
            }
            ]
            }];

            function testit(data) {
            alert(data.length + ' and ids are ' +data );
            for (var count = 0; count < data.length; count++) {

            }

            }
            $('#Tree').jstree({
            core: {
            data: data1,
            check_callback: false
            },
            checkbox: {
            three_state: false, // to avoid that fact that checking a node also check others
            whole_node: false, // to avoid checking the box just clicking the node
            tie_selection: false // for checking without selecting and selecting without checking
            },
            plugins: ['checkbox']
            })
            $('#Tree').on("check_node.jstree uncheck_node.jstree", function(e, data) {
            if (data.selected.length === 1) { alert(data.instance._model.data[data.selected].state['opened']); }
            testit(data.selected);
            });

            <link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
            <div id="Tree"></div>








            share|improve this answer













            Because of the strict mode you will get the exception that if you try to use get_bottom_checked



            TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them.
            at Function.invokeGetter (<anonymous>:2:14)



            You can use data.selected from your check or uncheck event handler if you just want the ids of selected nodes but if you need more than that you can use 'data.instance._model.data'. As you can see in my example I am trying to alert if there is only one item selected and that's state is open. In the code example, you can see the Alert if you open the `Europe1 and select the checkbox.






            var data1 = [{
            "id": "W",
            "text": "World",
            "state": {
            "opened": true
            },
            "children": [{
            "text": "Asia"
            },
            {
            "text": "Africa"
            },
            {
            "text": "Europe",
            "state": {
            "opened": false
            },
            "children": ["France", "Germany", "UK"]
            }
            ]
            }];

            function testit(data) {
            alert(data.length + ' and ids are ' +data );
            for (var count = 0; count < data.length; count++) {

            }

            }
            $('#Tree').jstree({
            core: {
            data: data1,
            check_callback: false
            },
            checkbox: {
            three_state: false, // to avoid that fact that checking a node also check others
            whole_node: false, // to avoid checking the box just clicking the node
            tie_selection: false // for checking without selecting and selecting without checking
            },
            plugins: ['checkbox']
            })
            $('#Tree').on("check_node.jstree uncheck_node.jstree", function(e, data) {
            if (data.selected.length === 1) { alert(data.instance._model.data[data.selected].state['opened']); }
            testit(data.selected);
            });

            <link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
            <div id="Tree"></div>








            var data1 = [{
            "id": "W",
            "text": "World",
            "state": {
            "opened": true
            },
            "children": [{
            "text": "Asia"
            },
            {
            "text": "Africa"
            },
            {
            "text": "Europe",
            "state": {
            "opened": false
            },
            "children": ["France", "Germany", "UK"]
            }
            ]
            }];

            function testit(data) {
            alert(data.length + ' and ids are ' +data );
            for (var count = 0; count < data.length; count++) {

            }

            }
            $('#Tree').jstree({
            core: {
            data: data1,
            check_callback: false
            },
            checkbox: {
            three_state: false, // to avoid that fact that checking a node also check others
            whole_node: false, // to avoid checking the box just clicking the node
            tie_selection: false // for checking without selecting and selecting without checking
            },
            plugins: ['checkbox']
            })
            $('#Tree').on("check_node.jstree uncheck_node.jstree", function(e, data) {
            if (data.selected.length === 1) { alert(data.instance._model.data[data.selected].state['opened']); }
            testit(data.selected);
            });

            <link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
            <div id="Tree"></div>





            var data1 = [{
            "id": "W",
            "text": "World",
            "state": {
            "opened": true
            },
            "children": [{
            "text": "Asia"
            },
            {
            "text": "Africa"
            },
            {
            "text": "Europe",
            "state": {
            "opened": false
            },
            "children": ["France", "Germany", "UK"]
            }
            ]
            }];

            function testit(data) {
            alert(data.length + ' and ids are ' +data );
            for (var count = 0; count < data.length; count++) {

            }

            }
            $('#Tree').jstree({
            core: {
            data: data1,
            check_callback: false
            },
            checkbox: {
            three_state: false, // to avoid that fact that checking a node also check others
            whole_node: false, // to avoid checking the box just clicking the node
            tie_selection: false // for checking without selecting and selecting without checking
            },
            plugins: ['checkbox']
            })
            $('#Tree').on("check_node.jstree uncheck_node.jstree", function(e, data) {
            if (data.selected.length === 1) { alert(data.instance._model.data[data.selected].state['opened']); }
            testit(data.selected);
            });

            <link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
            <div id="Tree"></div>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 3 at 0:28









            NarendraNarendra

            1,9651822




            1,9651822













            • Thanks. This got me very close to what I need. Is there a way to get the children from the selected parent? When I click a parent, all the children are selected, but in this example the selected is just the parent. Ultimately I just need all the checked children. Something like this: $('#mytree').jstree(true).get_bottom_selected(true); - Can i get this information from data.instance._model.data[data.selected] ?

              – user1904898
              Jan 3 at 16:15













            • When I click a parent, all the children are selected, but in this example the selected is just the parent. because I am passing three_state: false, // to avoid that fact that checking a node also check others

              – Narendra
              Jan 4 at 1:56



















            • Thanks. This got me very close to what I need. Is there a way to get the children from the selected parent? When I click a parent, all the children are selected, but in this example the selected is just the parent. Ultimately I just need all the checked children. Something like this: $('#mytree').jstree(true).get_bottom_selected(true); - Can i get this information from data.instance._model.data[data.selected] ?

              – user1904898
              Jan 3 at 16:15













            • When I click a parent, all the children are selected, but in this example the selected is just the parent. because I am passing three_state: false, // to avoid that fact that checking a node also check others

              – Narendra
              Jan 4 at 1:56

















            Thanks. This got me very close to what I need. Is there a way to get the children from the selected parent? When I click a parent, all the children are selected, but in this example the selected is just the parent. Ultimately I just need all the checked children. Something like this: $('#mytree').jstree(true).get_bottom_selected(true); - Can i get this information from data.instance._model.data[data.selected] ?

            – user1904898
            Jan 3 at 16:15







            Thanks. This got me very close to what I need. Is there a way to get the children from the selected parent? When I click a parent, all the children are selected, but in this example the selected is just the parent. Ultimately I just need all the checked children. Something like this: $('#mytree').jstree(true).get_bottom_selected(true); - Can i get this information from data.instance._model.data[data.selected] ?

            – user1904898
            Jan 3 at 16:15















            When I click a parent, all the children are selected, but in this example the selected is just the parent. because I am passing three_state: false, // to avoid that fact that checking a node also check others

            – Narendra
            Jan 4 at 1:56





            When I click a parent, all the children are selected, but in this example the selected is just the parent. because I am passing three_state: false, // to avoid that fact that checking a node also check others

            – Narendra
            Jan 4 at 1:56













            2














            According to this
            you can get all selected nodes on change event like this:



                $('#jstree').on('changed.jstree', function (e, data) {
            var i, j, r = ;
            for(i = 0, j = data.selected.length; i < j; i++) {
            r.push(data.instance.get_node(data.selected[i]).text);
            }
            $('#event_result').html('Selected: ' + r.join(', '));
            }).jstree();





            share|improve this answer






























              2














              According to this
              you can get all selected nodes on change event like this:



                  $('#jstree').on('changed.jstree', function (e, data) {
              var i, j, r = ;
              for(i = 0, j = data.selected.length; i < j; i++) {
              r.push(data.instance.get_node(data.selected[i]).text);
              }
              $('#event_result').html('Selected: ' + r.join(', '));
              }).jstree();





              share|improve this answer




























                2












                2








                2







                According to this
                you can get all selected nodes on change event like this:



                    $('#jstree').on('changed.jstree', function (e, data) {
                var i, j, r = ;
                for(i = 0, j = data.selected.length; i < j; i++) {
                r.push(data.instance.get_node(data.selected[i]).text);
                }
                $('#event_result').html('Selected: ' + r.join(', '));
                }).jstree();





                share|improve this answer















                According to this
                you can get all selected nodes on change event like this:



                    $('#jstree').on('changed.jstree', function (e, data) {
                var i, j, r = ;
                for(i = 0, j = data.selected.length; i < j; i++) {
                r.push(data.instance.get_node(data.selected[i]).text);
                }
                $('#event_result').html('Selected: ' + r.join(', '));
                }).jstree();






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 8 at 9:53









                leopal

                8011716




                8011716










                answered Jan 8 at 9:07









                palpal

                186110




                186110






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53855021%2fgeting-all-the-selected-nodes-in-jstree-on-check-event%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith