jstree

jsTree : How to get all nodes from jstree?

喜你入骨 提交于 2019-11-30 07:26:01
问题 How to get all nodes present in jsTree? I am building jsTree with xml Root -----A -----A1 -----A1.1 -----A1.2 -----A2 -----`A2.1` -----A2.2 -----B -----B1 -----B2 -----C -----C1 -----C1.1 -----C2.2 I want array of all nodes(ID) present in jsTree is as follows Expected output: [Root, A, A1, A1.1, A1.2, A2, A2.1, A2.2, B, B1, B2, C, C1, C1.1, C2.2] 回答1: From documentation: .get_json ( node , li_attr , a_attr ) This function returns an array of tree nodes converted back to JSON. More info about

Why doesn't jsTree open_all() work for me?

家住魔仙堡 提交于 2019-11-30 06:10:15
Started playing around with jQuery and the jsTree plugin yesterday, and have it successfully loading the tree with an AJAX call to a servlet. Now, I would like to have the tree open all the nodes after loading so I added a success function to the ajax attribute. However, I cannot seem to get the open_all() method to work properly. I'm very new to working with jQuery so I'm guessing it's something simple that I'm doing wrong. Firebug isn't showing any errors which rules out the dumb error of mistyped method name. I checked the documentation and I think I'm doing everything correctly according

How can I refresh the contents of a jsTree?

和自甴很熟 提交于 2019-11-30 06:01:44
I have loaded a jsTree with an AJAX call that returns JSON data. How can I refresh the tree so that it reloads its contents? Turns out is is as simple as calling: tree.jstree("refresh"); At version 3 you can reload the tree : $('#treeId').jstree(true).settings.core.data = newData; $('#treeId').jstree(true).refresh(); Aigiz var tree = jQuery.jstree._reference("#files"); tree.refresh(); or var tree = jQuery.jstree._reference("#files"); var currentNode = tree._get_node(null, false); var parentNode = tree._get_parent(currentNode); tree.refresh(parentNode); for jstree3 . I use destroy() function

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

本秂侑毒 提交于 2019-11-30 05:59:43
How can I get the id of the selected node in a jsTree ? function createNewNode() { alert('test'); var tree = $.tree.reference("#basic_html"); selectedNodeId = xxxxxxxxx; //insert instruction to get id here tree.create({ data : "New Node Name" }, selectedNodeId); } Nodes in jsTree are essentially wrapped list items. This will get you a reference to the first one. var n = $.tree.focused().get_node('li:eq(0)') You can replace $.tree.focused() if you have a reference to the tree. To get the id, take the first matched element if (n.length) id = n[0].id or you can use the jQuery attr function, which

How to associate a data to a node in jstree?

北慕城南 提交于 2019-11-30 04:54:23
$("#ifTree").jstree({ "plugins" : ["themes","html_data","ui","crrm"], "themes" : { "theme" : "apple", "dots" : true, "icons" : false } }); $("#createIf_c").click(function () { $("#ifTree").jstree("create",null,"inside", { "data" :{ title:"if",value:"expression"} }, function() {}, true); }); $("#display").click(function(){ var a = $.jstree._focused().get_selected(); alert(a.attr("value")); }); In this above code I have created a jstree and upon click of a button with id #createIf_c I am adding a node with title "if" but as I want some more data to be associated with this node , I have added

Recreate entire jstree instance with new json data

无人久伴 提交于 2019-11-30 04:50:57
I wish to replace the entire contents of a jstree tree with new json data. I'm using jsTree 1.0 downloaded July 25, 2011 from github Say I have this function... function init_my_tree(my_json_data) { $("#demo1").jstree({ themes: { "theme": "classic", "dots": false, "icons": true, "url": "//js.myliburl.com/jstree/themes/classic/style.css" }, json : { data : my_json_data }, plugins : [ "core","ui","themes", "json" ] }); } where demo1 refers to a <div id="demo1"></div> What I'm trying to do is to completely replace the tree with new data that I load from my server. For purposes of this question,

jstree types plugin does not display custom icons

时光怂恿深爱的人放手 提交于 2019-11-30 03:55:46
I have a simple HTML layout that looks like this: <div id="foo"> <ul> <li id="id1"><a href="#">some category 1</a> <ul><li><a href="#">some text</a></li></ul> <ul><li><a href="#">some text</a></li></ul> </li> <li id="id2"><a href="#">some category 2</a> <ul><li><a href="#">some text</a></li></ul> <ul><li><a href="#">some text</a></li></ul> </li> </ul> </div> The jstree definition looks like this $('#foo').jstree({ "core" : { "animation" : 0 }, "themes" : { "theme" : "classic", "dots" : false, "icons" : true }, "sort" : function (a, b) { return this.get_text(a) > this.get_text(b) ? 1 : -1; },

jsTree: progressive_render with ajax / render nodes from an array

ぐ巨炮叔叔 提交于 2019-11-30 03:34:00
问题 This is regarding the jsTree jQuery plugin. I've been struggling with this for a while now only to realise it's not (natively) possible to do, so I thought about the following solution to my problem below (which doesn't work). I have a tree that uses the json_data plugin with ajax. Once you open a specific node the result from the server is an array of over 1000 json nodes. The response is pretty fast but the rendering itself takes a while (the user experience is that he gets the annoying

JQuery JSTree - add a ToolTip

心已入冬 提交于 2019-11-30 03:31:13
问题 Is there a way to add a Tooltip to a JSTree node? I would like to display extra information when the user hovers over an element. I'm pretty dense when it comes to JQuery so there may be an obvious answer to this. Edit: Thanks to zzzz below, I am able to get a simple hover box to pop up. I still cannot apply a fancy JQuery Tooltip to it despite putting the tree's div within a fieldset as the instructions within the Tooltip page would suggest. 回答1: $("#my_tree).bind("hover_node.jstree",

Dual jsTree Implementation

落爺英雄遲暮 提交于 2019-11-29 15:47:24
问题 I am newbie to jsTree, I want to use dual jsTree. [left JsTrree] [ >> ] [right JsTrree] ">>" : Button for copy selected node from left to right jsTree I want to copy partial tree hierarchy from left to right jsTree. No duplication of node. I don't want to copy child node of selected node Only selected node from left jsTree merge into right jsTree as per right jsTree structure If user selected any node from left jsTree then on button(">>") click I want to copy partial tree from selected node