How do I get the id of the selected node in jsTree?

前端 未结 14 2392
北恋
北恋 2020-12-29 22:38

How can I get the id of the selected node in a jsTree?

function createNewNode() {
  alert(\'test\');
  var tree = $.tree.reference(\"#basic_html\");
  select         


        
14条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 23:03

    I was having problems getting the selected ids from a tree with MULTIPLE selections. This is the way I got them:

    var checked_ids = [];
    $("#your-tree-id").jstree('get_selected').each(function(){    
          checked_ids.push($(this).data('id'));                         
    });
    

提交回复
热议问题