Actualmente estoy usando js tree. Quiero obtener todos los objetos de nodo seleccionados.
Lo siguiente es cómo relleno mi jstree.
Mi código JS
$(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" />Estoy probando este código pero no obtengo el objeto de nodo seleccionado. Estoy tomando esto de los documentos jstree. Por favor, avíseme si tiene alguna idea de dónde estoy haciendo algo mal.
Gracias