Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
Get All Selected Node values in JS Tree

I'm currently using js tree. I want to get the all selected node object.

Following is how I populate my jstree.

My JS Code

   $(function () {

        $('#data').jstree({
            'core': {
                'data': [
                    {
                        "text": "Administration",
                        "children": [
                            {
                                "text": "Admin",
                                "children": [
                                    {
                                        "text": "Access",
                                        "children": [
                                            { "id": "1", "text": "Add" },
                                            { "id": "2", "text": "Edit" },
                                            { "id": "3", "text": "Delete" },

                                        ]
                                    },

                                ]
                            }
                        ]
                    }
                ]
            },
            'checkbox': {
                three_state: false,
                whole_node: false,    // should be set to false. otherwise checking the hidden checkbox
                // could be possible by clicking the node
                tie_selection: false, // necessary for whole_node to work
                cascade: 'up down'
            },
            'plugins': ["checkbox"]


        },

        ).bind("loaded.jstree", function (event, data) {

            $(this).jstree("open_all");

            $('.btnGetCheckedItem').click(function () {
                var checked_ids = [];
                var selectedNodes = $('#data').jstree("get_selected", true);
                console.log(selectedNodes);
                $.each(selectedNodes, function () {
                    /*  console.log(this.original);*/
                    checked_ids.push(this.id);
                });

                
                $('#idshow').text(checked_ids);
            });

        });

    });

HTML

  <div id="data"></div>
  <input class="btnGetCheckedItem" value="Get all checked items" type="button" />

I am trying this code but I am not getting the selected node object. I am taking this from the jstree documents Please let me know if you have any idea where I am doing something wrong?

Thank you

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda