jstree

how to append json variable as child nodes using “jstree” jquery plugin - no ajax

醉酒当歌 提交于 2019-12-19 09:56:29
问题 I have a jsTree using the json data format. Loading the root nodeset is fine. My problem is how to append child nodes to the parent node that was clicked. ANY help would be appreciated. Thanks! $("#tree-cat1") .bind("open_node.jstree", function (event, data) { console.log(data.rslt.obj.attr("id")); //eval(loadChild()); //at this point i need to append the result of loadChild() to the tree under the relevant node }) .jstree({ "json_data": { "data": eval(loadRoot()) }, "themes": {"theme":

JsTree with dnd plugin, always copy

末鹿安然 提交于 2019-12-19 09:39:47
问题 I have 2 trees using jsTree and dnd plugin. I want that each drag operation to be a copy instead of a move. There is a "copy_modifier" which works Ok when pressing a modifier key, but I want copy to be the default behavior without the modifier. Any ideas? Thanks, Adrian 回答1: Found a solution on http://groups.google.com/group/jstree I added the following section when configuring jsTree: "crrm": { "move": { "always_copy": "multitree" } } Hope this helps, Adrian 回答2: Adrian's solution won't work

JsTree Open a node then select a child node (using json_result)

大憨熊 提交于 2019-12-19 02:06:15
问题 I am having trouble with a JsTree I am using in an MVC2 project. I would like to create a function to deselect/close all nodes on the tree. Then open a specific node, and select a specific child node (I have the Id values for both). The trouble is that the select_node is always called before the open_node finishes, so the node is not selected, as the tree has not loaded the data yet, and the node ID does not exist. I first tried this function. $('#demo3').jstree('deselect_all'); $('#demo3')

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

别等时光非礼了梦想. 提交于 2019-12-18 12:08:52
问题 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); } 回答1: 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

jstree types plugin does not display custom icons

 ̄綄美尐妖づ 提交于 2019-12-18 11:32:02
问题 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,

jstree disable checkbox

孤街醉人 提交于 2019-12-18 04:14:56
问题 I am currently working on some POC using JS Tree plugin and related check box plugin. For certain nodes I need to check the check box by default and disable any further selection.I found the function to hide the check box .bind("load_node.jstree", function (e, data) { $(this).find('li[rel!=file]').find('.jstree-checkbox:first').hide(); }); instead of hiding the check box completely I want to find a way to disable check box for certain nodes 回答1: You will need to define a "disabled" type

dnd, how to restrict dropping to certain node types?

可紊 提交于 2019-12-17 23:32:52
问题 I have 37 different node types. I am trying to implement drag and drop. This works but I need to restrict exactly which types can be dragged and where they can be dropped. I can't find any useful information in the docs unfortunately (http://www.jstree.com/documentation). So far I have tried three methods: first: defining return values of true or false in the drag_check callback depending on the node type: $("#demo1").jstree({ "dnd" : { "drag_check" : function () { second: binding to the

How to get all checked nodes in jstree?

久未见 提交于 2019-12-17 20:42:29
问题 I need to export my nodes like this: function recursive_simplify(node){ if(node.children){ for(var i =0;i<node.children.length;i++){ node.children[i] = recursive_simplify(node.children[i]) } } delete node['metadata']; return node } $('body').on('click','.data-export', function () { var tree=$.jstree._reference('#reference-data-exchange'); var checked = tree.get_checked(); var result = []; for(var i=0, checkedLength = checked.length; i<checkedLength;i++) { var checkedJson = tree.get_json

creating dynamic jstree using alternative JSON format stored in array

烂漫一生 提交于 2019-12-17 19:54:26
问题 I am able to create jstree using alternative JSON format as below: $('#using_json_2').jstree({ 'core' : { 'data' : [ { "id" : "ajson1", "parent" : "#", "text" : "Simple root node" }, { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" }, { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" }, { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" }, ] } }); But it is quite static. I want it to be dynamic; in the sense that, number of rows could be variable and row properties

Open a jstree in a jquery dialog box

丶灬走出姿态 提交于 2019-12-14 04:02:21
问题 I've looked for every possible example, but couldn't find a complete one. I'm new to jQuery and javascript in general - I'm a backend developer. I'm trying to display the html results of an ajax call inside a jstree in a dialog box, and don't have the first clue what I'm doing. This is what I've come up with so far - can someone tell me what I'm doing wrong? (I had to retype this vs copy/paste, so there may be some minor typos). success: function(data) { $.getScript("js/jquery/jquery.jstree