Search Results

Search found 34 results on 2 pages for 'jstree'.

Page 1/2 | 1 2  | Next Page >

  • JsTree v1.0 - How to manipulate effectively the data from the backend to render the trees and operate correctly?

    - by Jean Paul
    Backend info: PHP 5 / MySQL URL: http://github.com/downloads/vakata/jstree/jstree_pre1.0_fix_1.zip Table structure for table discussions_tree -- CREATE TABLE IF NOT EXISTS `discussions_tree` ( `id` int(11) NOT NULL AUTO_INCREMENT, `parent_id` int(11) NOT NULL DEFAULT '0', `user_id` int(11) NOT NULL DEFAULT '0', `label` varchar(16) DEFAULT NULL, `position` bigint(20) unsigned NOT NULL DEFAULT '0', `left` bigint(20) unsigned NOT NULL DEFAULT '0', `right` bigint(20) unsigned NOT NULL DEFAULT '0', `level` bigint(20) unsigned NOT NULL DEFAULT '0', `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `h_label` varchar(16) NOT NULL DEFAULT '', `fulllabel` varchar(255) DEFAULT NULL, UNIQUE KEY `uidx_3` (`id`), KEY `idx_1` (`user_id`), KEY `idx_2` (`parent_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; /*The first element should in my understanding not even be shown*/ INSERT INTO `discussions_tree` (`id`, `parent_id`, `user_id`, `label`, `position`, `left`, `right`, `level`, `type`, `h_label`, `fulllabel`) VALUES (0, 0, 0, 'Contacts', 0, 1, 1, 0, NULL, '', NULL); INSERT INTO `discussions_tree` (`id`, `parent_id`, `user_id`, `label`, `position`, `left`, `right`, `level`, `type`, `h_label`, `fulllabel`) VALUES (1, 0, 0, 'How to Tag', 1, 2, 2, 0, 'drive', '', NULL); Front End : I've simplified the logic, it has 6 trees actually inside of a panel and that works fine $array = array("Discussions"); $id_arr = array("d"); $nid = 0; foreach ($array as $k=> $value) { $nid++; ?> <li id="<?=$value?>" class="label"> <a href='#<?=$value?>'><span> <?=$value?> </span></a> <div class="sub-menu" style="height:auto; min-height:120px; background-color:#E5E5E5" > <div class="menu" id="menu_<?=$id_arr[$k]?>" style="position:relative; margin-left:56%"> <img src="./js/jsTree/create.png" alt="" id="create" title="Create" > <img src="./js/jsTree/rename.png" alt="" id="rename" title="Rename" > <img src="./js/jsTree/remove.png" alt="" id="remove" title="Delete"> <img src="./js/jsTree/cut.png" alt="" id="cut" title="Cut" > <img src="./js/jsTree/copy.png" alt="" id="copy" title="Copy"> <img src="./js/jsTree/paste.png" alt="" id="paste" title="Paste"> </div> <div id="<?=$id_arr[$k]?>" class="jstree_container"></div> </div> </li> <!-- JavaScript neccessary for this tree : <?=$value?> --> <script type="text/javascript" > jQuery(function ($) { $("#<?=$id_arr[$k]?>").jstree({ // List of active plugins used "plugins" : [ "themes", "json_data", "ui", "crrm" , "hotkeys" , "types" , "dnd", "contextmenu"], // "ui" :{ "initially_select" : ["#node_"+ $nid ] } , "crrm": { "move": { "always_copy": "multitree" }, "input_width_limit":128 }, "core":{ "strings":{ "new_node" : "New Tag" }}, "themes": {"theme": "classic"}, "json_data" : { "ajax" : { "url" : "./js/jsTree/server-<?=$id_arr[$k]?>.php", "data" : function (n) { // the result is fed to the AJAX request `data` option return { "operation" : "get_children", "id" : n.attr ? n.attr("id").replace("node_","") : 1, "state" : "", "user_id": <?=$uid?> }; } } } , "types" : { "max_depth" : -1, "max_children" : -1, "types" : { // The default type "default" : { "hover_node":true, "valid_children" : [ "default" ], }, // The `drive` nodes "drive" : { // can have files and folders inside, but NOT other `drive` nodes "valid_children" : [ "default", "folder" ], "hover_node":true, "icon" : { "image" : "./js/jsTree/root.png" }, // those prevent the functions with the same name to be used on `drive` nodes.. internally the `before` event is used "start_drag" : false, "move_node" : false, "remove_node" : false } } }, "contextmenu" : { "items" : customMenu , "select_node": true} }) //Hover function binded to jstree .bind("hover_node.jstree", function (e, data) { $('ul li[rel="drive"], ul li[rel="default"], ul li[rel=""]').each(function(i) { $(this).find("a").attr('href', $(this).attr("id")+".php" ); }) }) //Create function binded to jstree .bind("create.jstree", function (e, data) { $.post( "./js/jsTree/server-<?=$id_arr[$k]?>.php", { "operation" : "create_node", "id" : data.rslt.parent.attr("id").replace("node_",""), "position" : data.rslt.position, "label" : data.rslt.name, "href" : data.rslt.obj.attr("href"), "type" : data.rslt.obj.attr("rel"), "user_id": <?=$uid?> }, function (r) { if(r.status) { $(data.rslt.obj).attr("id", "node_" + r.id); } else { $.jstree.rollback(data.rlbk); } } ); }) //Remove operation .bind("remove.jstree", function (e, data) { data.rslt.obj.each(function () { $.ajax({ async : false, type: 'POST', url: "./js/jsTree/server-<?=$id_arr[$k]?>.php", data : { "operation" : "remove_node", "id" : this.id.replace("node_",""), "user_id": <?=$uid?> }, success : function (r) { if(!r.status) { data.inst.refresh(); } } }); }); }) //Rename operation .bind("rename.jstree", function (e, data) { data.rslt.obj.each(function () { $.ajax({ async : true, type: 'POST', url: "./js/jsTree/server-<?=$id_arr[$k]?>.php", data : { "operation" : "rename_node", "id" : this.id.replace("node_",""), "label" : data.rslt.new_name, "user_id": <?=$uid?> }, success : function (r) { if(!r.status) { data.inst.refresh(); } } }); }); }) //Move operation .bind("move_node.jstree", function (e, data) { data.rslt.o.each(function (i) { $.ajax({ async : false, type: 'POST', url: "./js/jsTree/server-<?=$id_arr[$k]?>.php", data : { "operation" : "move_node", "id" : $(this).attr("id").replace("node_",""), "ref" : data.rslt.cr === -1 ? 1 : data.rslt.np.attr("id").replace("node_",""), "position" : data.rslt.cp + i, "label" : data.rslt.name, "copy" : data.rslt.cy ? 1 : 0, "user_id": <?=$uid?> }, success : function (r) { if(!r.status) { $.jstree.rollback(data.rlbk); } else { $(data.rslt.oc).attr("id", "node_" + r.id); if(data.rslt.cy && $(data.rslt.oc).children("UL").length) { data.inst.refresh(data.inst._get_parent(data.rslt.oc)); } } } }); }); }); // This is for the context menu to bind with operations on the right clicked node function customMenu(node) { // The default set of all items var control; var items = { createItem: { label: "Create", action: function (node) { return {createItem: this.create(node) }; } }, renameItem: { label: "Rename", action: function (node) { return {renameItem: this.rename(node) }; } }, deleteItem: { label: "Delete", action: function (node) { return {deleteItem: this.remove(node) }; }, "separator_after": true }, copyItem: { label: "Copy", action: function (node) { $(node).addClass("copy"); return {copyItem: this.copy(node) }; } }, cutItem: { label: "Cut", action: function (node) { $(node).addClass("cut"); return {cutItem: this.cut(node) }; } }, pasteItem: { label: "Paste", action: function (node) { $(node).addClass("paste"); return {pasteItem: this.paste(node) }; } } }; // We go over all the selected items as the context menu only takes action on the one that is right clicked $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).each(function(index,element) { if ( $(element).attr("id") != $(node).attr("id") ) { // Let's deselect all nodes that are unrelated to the context menu -- selected but are not the one right clicked $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); } }); //if any previous click has the class for copy or cut $("#<?=$id_arr[$k]?>").find("li").each(function(index,element) { if ($(element) != $(node) ) { if( $(element).hasClass("copy") || $(element).hasClass("cut") ) control=1; } else if( $(node).hasClass("cut") || $(node).hasClass("copy")) { control=0; } }); //only remove the class for cut or copy if the current operation is to paste if($(node).hasClass("paste") ) { control=0; // Let's loop through all elements and try to find if the paste operation was done already $("#<?=$id_arr[$k]?>").find("li").each(function(index,element) { if( $(element).hasClass("copy") ) $(this).removeClass("copy"); if ( $(element).hasClass("cut") ) $(this).removeClass("cut"); if ( $(element).hasClass("paste") ) $(this).removeClass("paste"); }); } switch (control) { //Remove the paste item from the context menu case 0: switch ($(node).attr("rel")) { case "drive": delete items.renameItem; delete items.deleteItem; delete items.cutItem; delete items.copyItem; delete items.pasteItem; break; case "default": delete items.pasteItem; break; } break; //Remove the paste item from the context menu only on the node that has either copy or cut added class case 1: if( $(node).hasClass("cut") || $(node).hasClass("copy") ) { switch ($(node).attr("rel")) { case "drive": delete items.renameItem; delete items.deleteItem; delete items.cutItem; delete items.copyItem; delete items.pasteItem; break; case "default": delete items.pasteItem; break; } } else //Re-enable it on the clicked node that does not have the cut or copy class { switch ($(node).attr("rel")) { case "drive": delete items.renameItem; delete items.deleteItem; delete items.cutItem; delete items.copyItem; break; } } break; //initial state don't show the paste option on any node default: switch ($(node).attr("rel")) { case "drive": delete items.renameItem; delete items.deleteItem; delete items.cutItem; delete items.copyItem; delete items.pasteItem; break; case "default": delete items.pasteItem; break; } break; } return items; } $("#menu_<?=$id_arr[$k]?> img").hover( function () { $(this).css({'cursor':'pointer','outline':'1px double teal'}) }, function () { $(this).css({'cursor':'none','outline':'1px groove transparent'}) } ); $("#menu_<?=$id_arr[$k]?> img").click(function () { switch(this.id) { //Create only the first element case "create": if ( $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).length ) { $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).each(function(index,element){ switch(index) { case 0: $("#<?=$id_arr[$k]?>").jstree("create", '#'+$(element).attr("id"), null, /*{attr : {href: '#' }}*/null ,null, false); break; default: $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); break; } }); } else { $.facebox('<p class=\'p_inner error bold\'>A selection needs to be made to work with this operation'); setTimeout(function(){ $.facebox.close(); }, 2000); } break; //REMOVE case "remove": if ( $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).length ) { $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).each(function(index,element){ //only execute if the current node is not the first one (drive) if( $(element).attr("id") != $("div.jstree > ul > li").first().attr("id") ) { $("#<?=$id_arr[$k]?>").jstree("remove",'#'+$(element).attr("id")); } else $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); }); } else { $.facebox('<p class=\'p_inner error bold\'>A selection needs to be made to work with this operation'); setTimeout(function(){ $.facebox.close(); }, 2000); } break; //RENAME NODE only one selection case "rename": if ( $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).length ) { $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).each(function(index,element){ if( $(element).attr("id") != $("div.jstree > ul > li").first().attr("id") ) { switch(index) { case 0: $("#<?=$id_arr[$k]?>").jstree("rename", '#'+$(element).attr("id") ); break; default: $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); break; } } else $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); }); } else { $.facebox('<p class=\'p_inner error bold\'>A selection needs to be made to work with this operation'); setTimeout(function(){ $.facebox.close(); }, 2000); } break; //Cut case "cut": if ( $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).length ) { $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).each(function(index,element){ switch(index) { case 0: $("#<?=$id_arr[$k]?>").jstree("cut", '#'+$(element).attr("id")); $.facebox('<p class=\'p_inner teal\'>Operation "Cut" successfully done.<p class=\'p_inner teal bold\'>Where to place it?'); setTimeout(function(){ $.facebox.close(); $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id")); }, 2000); break; default: $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); break; } }); } else { $.facebox('<p class=\'p_inner error bold\'>A selection needs to be made to work with this operation'); setTimeout(function(){ $.facebox.close(); }, 2000); } break; //Copy case "copy": if ( $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).length ) { $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).each(function(index,element){ switch(index) { case 0: $("#<?=$id_arr[$k]?>").jstree("copy", '#'+$(element).attr("id")); $.facebox('<p class=\'p_inner teal\'>Operation "Copy": Successfully done.<p class=\'p_inner teal bold\'>Where to place it?'); setTimeout(function(){ $.facebox.close(); $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); }, 2000); break; default: $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); break; } }); } else { $.facebox('<p class=\'p_inner error bold\'>A selection needs to be made to work with this operation'); setTimeout(function(){ $.facebox.close(); }, 2000); } break; case "paste": if ( $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).length ) { $.jstree._reference("#<?=$id_arr[$k]?>").get_selected(false, true).each(function(index,element){ switch(index) { case 0: $("#<?=$id_arr[$k]?>").jstree("paste", '#'+$(element).attr("id")); break; default: $("#<?=$id_arr[$k]?>").jstree("deselect_node", '#'+$(element).attr("id") ); break; } }); } else { $.facebox('<p class=\'p_inner error bold\'>A selection needs to be made to work with this operation'); setTimeout(function(){ $.facebox.close(); }, 2000); } break; } }); <? } ?> server.php $path='../../../..'; require_once "$path/phpfoo/dbif.class"; require_once "$path/global.inc"; // Database config & class $db_config = array( "servername"=> $dbHost, "username" => $dbUser, "password" => $dbPW, "database" => $dbName ); if(extension_loaded("mysqli")) require_once("_inc/class._database_i.php"); else require_once("_inc/class._database.php"); //Tree class require_once("_inc/class.ctree.php"); $dbLink = new dbif(); $dbErr = $dbLink->connect($dbName,$dbUser,$dbPW,$dbHost); $jstree = new json_tree(); if(isset($_GET["reconstruct"])) { $jstree->_reconstruct(); die(); } if(isset($_GET["analyze"])) { echo $jstree->_analyze(); die(); } $table = '`discussions_tree`'; if($_REQUEST["operation"] && strpos($_REQUEST["operation"], "_") !== 0 && method_exists($jstree, $_REQUEST["operation"])) { foreach($_REQUEST as $k => $v) { switch($k) { case 'user_id': //We are passing the user_id from the $_SESSION on each request and trying to pick up the min and max value from the table that matches the 'user_id' $sql = "SELECT max(`right`) , min(`left`) FROM $table WHERE `user_id`=$v"; //If the select does not return any value then just let it be :P if (!list($right, $left)=$dbLink->getRow($sql)) { $sql = $dbLink->dbSubmit("UPDATE $table SET `user_id`=$v WHERE `id` = 1 AND `parent_id` = 0"); $sql = $dbLink->dbSubmit("UPDATE $table SET `user_id`=$v WHERE `parent_id` = 1 AND `label`='How to Tag' "); } else { $sql = $dbLink->dbSubmit("UPDATE $table SET `user_id`=$v, `right`=$right+2 WHERE `id` = 1 AND `parent_id` = 0"); $sql = $dbLink->dbSubmit("UPDATE $table SET `user_id`=$v, `left`=$left+1, `right`=$right+1 WHERE `parent_id` = 1 AND `label`='How to Tag' "); } break; } } header("HTTP/1.0 200 OK"); header('Content-type: application/json; charset=utf-8'); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Pragma: no-cache"); echo $jstree->{$_REQUEST["operation"]}($_REQUEST); die(); } header("HTTP/1.0 404 Not Found"); ?> The problem: DND *(Drag and Drop) works, Delete works, Create works, Rename works, but Copy, Cut and Paste don't work

    Read the article

  • Programatically Drop an External Div in JSTree

    - by Ted Mosbey
    I have a grid (slickgrid) which creates and destroys rows on the fly. I know jstree uses .jstree-draggable to find the external drag targets, but applying them to the grid rows doesn't work - such that I've thought of using the grid drag, and on finish of the grid drag I want to call the jstree "drag_finish": function (data) jQuery.jstree._reference($("#Tree")).dnd_finish(); The problem is that there is some null data. How would I Programatically Drop an External Div? How does jstree apply the .jstree-draggable targets? I could add the .jstree-draggable class to the grid drag helper, but it doesnt seem to fire when dropped on the tree although it clearly has the class. Any guidance would be greatly appreciated. Regards.

    Read the article

  • JSTree, is it possible to add a handle?

    - by nobosh
    I'm very interested in using JSTree for a Sortable list that allows for nesting. The problem is, in my list items I want things like checkboxes, etc... which isn't possible because the entire list is draggable with JSTREE. Is there a way to add a handler to JSTree so only when the handler is clicked the list is draggable? That would allow me to add all kinds of good stuff in the list that can be interacted with by the user. http://www.jstree.com/ Thanks

    Read the article

  • jstree dynamic JSON data from django

    - by danspants
    I'm trying to set up jsTree to dynamically accept JSON data from django. This is the test data i have django returning to jstree: result=[{ "data" : "A node", "children" : [ { "data" : "Only child", "state" : "closed" } ], "state" : "open" },"Ajax node"] response=HttpResponse(content=result,mimetype="application/json") this is the jstree code I'm using: jQuery("#demo1").jstree({ "json_data" : { "ajax" : { "url" : "/dirlist", "data" : function (n) { return { id : n.attr ? n.attr("id") : 0 }; }, error: function(e){alert(e);} } }, "plugins" : [ "themes","json_data"] }); All I get is the ajax loading symbol, the ajax error response is also triggered and it alerts "undefined". I've also tried simpleJson encoding in django but with the same result. If I change the url so that it is receiving a JSON file with identical data, it works as expected. Any ideas on what the issue might be?

    Read the article

  • [javascript] Populating jsTree based on XML data uploaded to server folder

    - by PFM
    tl:dr How can I populate jsTree based on a folder location instead of an exact XML url? I'm looking for a little direction on this project. Currently I am trying to copy file structures of hard drives as XML files and recreate them using jsTree on the webserver for a completely independent version of the file structure. I have some python script that outputs XML files that are formed to jsTree and automatically uploads to a folder on the server. The problem is now I am a little lost because I have to manually enter each XML file into jsTree code for it to display so I have multiple entries like this: $("#tree1") .jstree({ "plugins" : [ "themes", "xml_data", "ui", "search", "types" ], "xml_data" : { "ajax" : { "url" : "./XML_DATA/DRIVE1.xml" }, "xsl" : "nest" }, I see in the documentation that instead of populated by the direct file the folders are populated by "server.php" but no where in the php code does it point to any directories or files. After considering the problem I thought of a few solutions and could use some advice on them: Should I be trying to write php code to automatically look through my XML_DATA folder to upload each XML file? Should I just upload all the XML to mySQL and populate my tree based on that? Should the javascript be the code looking through the server's folder for XML files? All the XML is formed the same way but the number of XML files on the server will increase and will have to be refreshed as well as they will be overwritten with changes. Any direction would be appreciated, thanks.

    Read the article

  • jsTree async with preloaded data.

    - by Paul Knopf
    I am trying to make a tree view be async. When the page is rendered, there is default tree items displayed. jsTree tries to reload the root anyway. I want the page to render (with jsTree init'ed) with default items rendered from browser, not the ajax call. Then we the user tries to go deeper, thats when I want to do do the ajax calls. Any help is appreciated. Thanks!

    Read the article

  • jsTree Selecte most nested node

    - by niao
    Greetings, I just started to use jsTree and I have a question for you guys. How can I select only the most nested node - the node which doesn't have any children. additionally, when this node is selected, I would like to submit my form which contains the jsTree. How can I then access selected node?

    Read the article

  • jstree select node

    - by niao
    Greetings, I am using jsTree to generatate my hierarchical data. JsTree is generated as follows: $(function() { $("#industries").tree({ data: { type: "json", opts: { url: "/Admin/GetIndustries/" } } }); }); it works find and the jsonresult is something like: [{"attributes":[],"data":{"title":"Adwokaci, Notariusze","id":"1a051101-c3fa-48f2-b2e1-c60d1b67ea22"},"children":[{"attributes":[],"data":{"title":"Kancelarie adwokackie","id":"26d6cff1-3c7f-4a2f-bf5a-422e08127b43" my question is: how can I save id of selected node in some hidden field? I do something like this: <script type="text/javascript"> $("#industries").click(function() { var tree = $.tree.reference("industries"); var t = $.tree.focused(); if (t.selected) t.selected; else alert("Select a node first"); alert(t.id); }); but it does not work. Can someone please help me?

    Read the article

  • Checking a checkbox node programmatically with jsTree

    - by Raj
    In a tree built with jsTree, I have the text within the <a> tag sitting in a variable. I would like to check that node. How can I do so? I am currently finding that node, using jQuery, and altering its class. However, this does not repair the parent node by making the parent undetermined in its class. I tried doing $('.colors').jstree("checkbox_repair"), but that didn't seem to do anything. It would be great if someone could actually answer both those questions, since they are related to the same problem. Here is a jsFiddle, illustrating the issue-- http://jsfiddle.net/thapar/5XAjU/

    Read the article

  • Store JsTree order back into database

    - by Scott
    Hi I am using JsTree and got some of it working with my database. Such as deleting a node, renaming a node, etc. I am having problems with saving the ROOT folders order back to the database. When I move the root folders, it doesnt save order. When I move the sub folders around, it saves order fine. Anyone know what I am doing wrong? I think it's my javascript for the onmove. here's a demo of what I am talking about. http://healthsharing.com/jstree/demo.php

    Read the article

  • Need help replicating directory structure with ColdFusion and jsTree

    - by Derek
    I am using this new jQuery plugin called jsTree www.jstree.com and using the HTML datasource. I am also using ColdFusion 7 with cfdirectory and filtering out files, so just dirs. I need to recreate the directory structure in the image, well any dir structure I give it actually. I am having a heck of a time with the logic. variables.imageDirectoriesLen = 8 in this scenario cause I am outputting from the middle of the actual file path, not from begining. Thanks for the help. Derek this is what I have so far <cfoutput query="clientImageDirsFilter"> <cfset nextLen = 0 /> <cfset nextDir = "" /> <cfset nextRowCnt = currentRow+1 /> <cfset nextDir = clientImageDirsFilter.directory[nextRowCnt] & "\" & clientImageDirsFilter.name[nextRowCnt] /> <cfset nextLen = listLen(nextDir, "\") /> <cfset currLen = listLen(clientImageDirsFilter.directory & "\" & clientImageDirsFilter.name,"\") /> <cfif currLen eq nextLen> <li rel="folder" id="node_#randRange(1,99999)#"><a href="##"><ins>&nbsp;</ins>#clientImageDirsFilter.name#</a></li> <cfelseif nextLen lt currLen> <cfif nextLen eq 0> #repeatString("</li></ul>",(currLen-nextLen-variables.imageDirectoriesLen))# </cfif> <cfelse> <ul> <li rel="folder" id="node_#randRange(1,99999)#"><a href="##"><ins>&nbsp;</ins>#clientImageDirsFilter.name#</a> <ul> </cfif>

    Read the article

  • Configuring jstree right-click contextmenu for different node types

    - by MGOwen
    I've seen an example somewhere online showing how to customise the appearance of jstree's right-click context menu (using contextmenu plugin). For example, allow my users to delete "documents" but not "folders" (by hiding the "delete" option from the context menu for folders). Now I can't find that example. Can anyone point me in the right direction? The official documentation didn't really help.

    Read the article

  • jsTree: async loading

    - by vandalo
    Hello everyone, I am trying to use this jQuery plugin (jsTree) in one of my project. All the others I've found haven't been recently updated. Anyway, I am using this plugin to load a folder structure, but I would like to do this operation async. The examples I've found on their site (called async) are ridiculous. I've tried to check on the Internet but it seems that most people load the whole tree. I would like to load a branch on every single node click. I am using JSON. Thank in advance

    Read the article

  • How to preselect nodes using jsTree jQuery plug-in

    - by Ed Schembor
    I am using the jsTree jQuery plug-in with its "Checkbox" plug-in and using an async http request to lazy-load each level of the tree. All works great, except that I cannot get the tree to pre-select certain nodes after the first level. I am using the "selected" attribute to provide an array of ID's to preselect. ID's in the top level of the tree are correctly pre-selected. However, ID's in lower levels of the tree are not selected when the level loads. Am I missing something? Here is the constructor code: $(sDivID).tree( { data : { async : true, opts : {url : sURL} }, plugins:{ "checkbox" : {three_state : false} }, selected : myArrayOfIDs, ui:{ theme_name : "checkbox", dots : false, animation : 400 }, callback : { beforedata : function(NODE, TREE_OBJ) { return { id : $(NODE).attr("id") || 0, rand : Math.random().toString() } } } } )

    Read the article

  • jsTree causes that links on whole page are broken

    - by niao
    Greetings, I have the following problem. In my asp.net mvc page (which is a partial view) I create an instance of jsTree as follows: <script type="text/javascript"> $(function() { $("#industries").tree({ callback: { onselect: function(NODE, TREE_OBJ) { $("#SelectedIndustryROWGUID").val($(NODE).attr("id")); $("#resultMessage").append($(NODE).attr("rel")); } }, data: { type: "json", async: true, opts: { method: "GET", url: "/CreateMessage/GetIndustries/" } } }); }); this works fine but then, when I click on any link on the page, it does not work. The links are executed when I choose "open in new tab" option from context menu. Can someone please help me with this?

    Read the article

  • jsTree: Prevent before and after TYPE, only use inside

    - by Nic Hubbard
    I am using jsTree which is very nice. When dragging and dropping, I don't really care for the before and after types, I only want to use inside. Meaning, I am only concerned about that parent that a child is dropped into, rather than where the order is with other elements INSIDE the parent. So, I wanted to build my callback, so it always refers to the parent node that it is inside. But, it is not fool proof, yet. onmove : function (NODE,REF_NODE,TYPE,TREE_OBJ,RB) { if (TYPE == 'inside') { alert('Item to move:'+$(NODE).attr('rel')+' to '+$(REF_NODE).attr('rel')+' '+TYPE); } else if (TYPE == 'after') { alert('Item to move:'+$(NODE).attr('rel')+' to '+$(REF_NODE).parent().parent('li').attr('rel')+' '+TYPE); } }, Does anyone have suggestions, how I can change my callback, so that the REF_NODE is always the parent that the NODE is moved into? Rather than a sibling of, which is a child of the parent?

    Read the article

  • JSTree select_node event and checkbox

    - by Ted Mosbey
    Hi there! I have a jstree in which I used the select_node event to toggle nodes(expand), and have therefore removed the toggle arrows in the tree since they look ugly and I've no need for them. Now I've added the checkbox plugin to use within the tree, but have found the select_node event is disabled when the plugin is active. How would I toggle my nodes with the checkbox plugin active, without re-adding the ugly toggle arrows? I could do it in the check/uncheck event, but I don't want to check/uncheck everytime I expand a node.

    Read the article

  • jstree will not fire onchange event

    - by vasion
    i have been really stuck on this. this is the code: js: var treeoptions={"data":{"type":"json","opts":{"url":"\/surveytags\/treejson"}}}; $('#treecontainer').tree(treeoptions); $("#treecontainer").tree({ callback : { ondblclk : function (node, tree) { alert(node.id); }, onmove : function (node,ref,type){ data= new Object(); data.node= new Object(); data.node.id = node.id; data.ref=new Object(); data.ref.id = ref.id; data.type = type; moveitem(data); }, onchange : function (){ alert('focused'); }, oncreate : function(node){ alert('create'); alert(node.data); } } }); this is the json: {"attributes":{"id":"1"},"data":{"title":"root"},"children":[{"attributes":{"id":"2"},"data":{"title":"blah"},"children":[{"attributes":{"id":"3"},"data":{"title":"tworows down"}},{"attributes":{"id":"4"},"data":{"title":"tooope"}}]}]} it loads. other events fire. BUT onchange will not...

    Read the article

  • Renaming node from jsTree inside a mvc2 form.

    - by Stef
    I've the following code: <% using (Html.BeginForm("Update", "SkillLevel", FormMethod.Post, new { id = "TheForm" })) { %> <div id="demo3" class="demo"> <ul> <li id="shtml_1"> <a href="#">Root node 1</a> <ul> <li id="shtml_2"> <a href="#">Child node 1</a> </li> <li id="shtml_3"> <a href="#">Child node 2</a> </li> </ul> </li> <li id="shtml_4"> <a href="#">Root node 2</a> </li> </ul> </div> The problem is that when I rename a node, i press Enter to complete the rename. But when pressing Enter, the form gets submitted and the new value is never changed in the tree. How to sole this ?

    Read the article

  • jsTree and SVG Editor conflict in active selected items?

    - by marknt15
    Hi, I'm using jsTree and SVG-Edit in the same file but there is a conflict in the active selected item. For example I clicked a tree item then I cannot draw in the svgcanvas div anymore. Maybe because of you click the item in jsTree then it's always selected and the svgcanvad div will not be active anymore? Any help, tips or tutorials will help. Thanks, Mark

    Read the article

  • jsTree: How to create a new ID for the new added node?

    - by marknt15
    Hi, I can normally get the ID of the default tree nodes but my problem is onCreate then jsTree will add a new node but it doesn't have an ID. My question is how can I add an ID to the newly created tree node? What I'm thinking to do is adding the ID HTML attribute to the newly created tree node but how? I need to get the ID of all of the nodes because it will serve as a reference for the node's respective div storage. HTML code: <div class="demo" id="demo_1"> <ul> <li id="phtml_1" class="file"><a href="#"><ins>&nbsp;</ins>Root node 1</a></li> <li id="phtml_2" class="file"><a href="#"><ins>&nbsp;</ins>Root node 2</a></li> </ul> </div> JS code: $("#demo_1").tree({ ui : { theme_name : "apple" }, callback : { onrename : function (NODE, TREE_OBJ) { alert(TREE_OBJ.get_text(NODE)); alert($(NODE).attr('id')); } } }); Cheers, Mark

    Read the article

  • jquery jstree or dynatree parent node don't get selected

    - by mazhar
    I have used jquery jstree or dynatree using check boxes and found the same logic The thing is that the if for example there is a parent and 4 child. a) i select all the 4 child (parent get auto selected) the 4 child and the parent node id get posted to the controller. b) But if i select less then 4 children (parent get auto selected) only child node ids get posted to the controller. Is there any way even if i select less then 4 children all my selected nodes included the parent get posted to the controller?

    Read the article

  • PHP: Convert <ul> <li> Tree HTML tag to an array

    - by marknt15
    Hi, I'm using jsTree and I need to convert this HTML tag tree code <ul> <li> to a PHP array. The jsTree HTML tag will be passed to PHP to be parsed and store in a structured tree PHP array(see below for the PHP array structure). Additional question: Is my desired PHP array structure good or you can suggest a good structure? I'm open for suggestions. Thanks in advance :) Cheers, Mark jsTree Screenshot: HTML Tree String: <ul class="ltr"> <li id="phtml_1" class=" open"> <a style="" class=" " href="#"><ins>&nbsp;</ins>Folder 1</a> <ul> <li class="leaf" id="phtml_2"> <a style="" class=" " href="#"><ins>&nbsp;</ins>Child 1.1</a> </li> <li class="open" id="phtml_3"> <a style="" class=" " href="#"><ins>&nbsp;</ins>Folder 1.1</a> <ul> <li class="leaf last" rel="default"> <a href="" style="" class=" "><ins>&nbsp;</ins>Child 1.1.1</a> </li> </ul> </li> <li class="last open" rel="default"> <a href="" style="" class=" "><ins>&nbsp;</ins>Folder 1.2</a> <ul> <li class="leaf" rel="default"> <a href="" style="" class=" "><ins>&nbsp;</ins>Child 1.2.1</a> </li> <li class="leaf last" rel="default"> <a href="" style="" class=" "><ins>&nbsp;</ins>Child 1.2.2</a> </li> </ul> </li> </ul> </li> <li id="phtml_5" class="file open"> <a style="" class=" " href="#"><ins>&nbsp;</ins>Folder 2</a> <ul> <li class="leaf" rel="default"> <a href="" style="" class=" "><ins>&nbsp;</ins>Child 2.1</a> </li> <li class="leaf last" rel="default"> <a href="" style="" class="clicked"><ins>&nbsp;</ins>Child 2.2</a> </li> </ul> </li> <li class="leaf last" rel="default"> <a href="" style="" class=" "><ins>&nbsp;</ins>Outer Child</a> </li> </ul> PHP Array Structure: <?php $tree_array = array( 'Folder 1' => array( 'Child 1.1', 'Folder 1.1' => array( 'Child 1.1.1' ), 'Folder 1.2' => array( 'Child 1.2.1', 'Child 1.2.2' ), ), 'Folder 2' => array( 'Child 2.1', 'Child 2.2' ), 'Outer Child' ); echo '<pre>',print_r($tree_array),'</pre>'; ?> PHP print_r Output: Array ( [Folder 1] => Array ( [0] => Child 1.1 [Folder 1.1] => Array ( [0] => Child 1.1.1 ) [Folder 1.2] => Array ( [0] => Child 1.2.1 [1] => Child 1.2.2 ) ) [Folder 2] => Array ( [0] => Child 2.1 [1] => Child 2.2 ) [0] => Outer Child )

    Read the article

1 2  | Next Page >