Comments (6)
Version 0.11 of jqTree has the tree.init event. This event is fired when the tree data is loaded. It is not documented yet.
JqTree does not support mouse-over, but you can write it yourself like this:
$tree.on('hover', '.title', function(e) {
var $li = $(e.target).closest('li');
var node = $li.data('node');
console.log(node);
});
I'm not sure if I want to add the getParents function to jqTree because I don't know how many people will use it. You could however implement it in your own code, like this:
var node = $tree.tree('getNodeByName', 'Hadrosaurids');
var parents = [];
var parent = node.parent;
while (parent) {
parents.push(parent);
parent = parent.parent;
}
It should indeed be possible to display an empty folder. More people have mentioned this, and I'm still thinking about the best api for this. Perhaps an empty children property is a good option.
from jqtree.
maybe typeof() is also good.
i downloaded the latest version 0.11 and the tree.init event works :)
but when i try to get the selected node it returns null!
but i can see that a node (by cookie or savestate ) has been selected on startup, but when i try to get the selected node on the tree.init event it returns null.
here is the code:
$tree.bind(
'tree.init',
function(e)
{
var node = $tree.tree('getSelectedNode');
alert(node)
}
);
For my application to work i realy need to get the selected node on tree.init, so i can fill my second tree with the associated files. any ideas?
from jqtree.
Strange. I tried it with example2 (http://mbraak.github.com/jqTree/examples/example2.html) with the following code:
$tree = $('#tree1');
$tree.tree({
selectable: true,
saveState: true
});
$tree.bind('tree.init', function() {
var node = $tree.tree('getSelectedNode');
console.log(node);
});
A small detail: for saveState to work, nodes must have an id property. Example:
{
label: 'Sauropodomorphs',
id: 16
}
from jqtree.
well i use ID's and labels.
this is my tree config:
{
data: data,
autoOpen: 0,
dragAndDrop: false,
selectable: true,
saveState: true
}
But on the tree.init event only null returns.
Like i said "i use ID's for nodes"
I looked at example2 but the log is empty. i use google chrome maybe thats the issue?
** EDIT **
IE also returns null. just checked it.
from jqtree.
I'm afraid you found an error in jqTree. If you call getSelectedNode in the tree.init event it returns null.
However, you can call getSelectedNode after initializing the tree:
$tree.tree({
data: data,
selectable: true,
saveState: true
});
var node = $tree.tree('getSelectedNode');
console.log(node);
from jqtree.
Yes that works!
but i found also a workaround for the tree.init event
$tree.bind(
'tree.init',
function(e)
{
var $li = $tree.find('li.selected');
var node = $li.data('node');
alert(node.name)
}
);
from jqtree.
Related Issues (20)
- Question: Is there a way to know when dragging a node if it's dropped at its same place before dragging or not? HOT 4
- Issue while trying to load a little bit large amount of nodes HOT 1
- Disable opening folders during drag & drop HOT 5
- Selected Node Problem HOT 2
- Possible to open a particular node at jqTree creation time? HOT 1
- Cannot find node with getNodeById HOT 12
- Functions getNextNode() and getPreviousNode() operate differently based on whether node is open or closed HOT 4
- Question: Is is possible to find a node using its path? HOT 1
- What can I do if I choose only child multiple times HOT 6
- How to export and import jqTree data? HOT 9
- Rename selected node HOT 3
- Autoscroll - top level dragged item no scroll over the items under it. HOT 20
- Feature: ES6 support HOT 9
- Behavior changed with 1.7.0 HOT 3
- Set jQuery as a peer dependency
- Fix eslint import error
- Is documentation page dead? HOT 4
- Inconsistent/incorrect drag & drop node highlighting HOT 9
- New root node missing icon HOT 3
- AddToSelection doesn't seem to use "mustSetFocus" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jqtree.