Comments (10)
Yes, I think that getNodeById should compare the ids 'unstrict'. Converting the ids to strings is probably a good way to do this.
from jqtree.
I've thought in a better way. There is another issue I guess with the way getNodeByXXX is currently implemented. jqTree should keep they indexed by an object/hash. That way, not only it should perform better but CoffeeScript wouldn't do any strict comparison if you're accessing the hash by id.
For example: @nodeById[id] and @nodeByName[id] would translate to this.nodeByXXX[xxx] and then no strict comparison would be performed.
And it would also perform much better than iterating over the entire tree. What do you think?
from jqtree.
In which situation do you use the function getNodeById? Are there any performance issues?
from jqtree.
Actually, I'm not using getNodeById anymore since yesterday and just using my internal map. This is more of a design decision than one based on performance. But here is the typical usage for getting the node from an id:
You have a button set in a <div data-id=2>buttons here</div>. Then you have a live event handler on those buttons and you get the id from their parent's div. Then you'll issue some AJAX request. Usually in my request's response I have access to the id of the created/updated new element so that I don't even need to store the id from the button's parent div.
Finally I need to do some operation where I need the id. For example, if it is a create action I'll need to append some node and I'll need a node as returned by getNodeById for that. But actually I've added the node information to my internal fields hash on onCreateLi handler.
from jqtree.
I can see the use for a fast getNodeById function. Do you also use getNodeByName? I only use it in the unit tests myself.
from jqtree.
Never used it.
from jqtree.
The getNodeById comparison is now less strict. It uses the javascript '=='.
I'm working on a performance improvement getNodeById that uses an index.
from jqtree.
Great, thanks :)
from jqtree.
Performance improvement is implemented in version 0.10
from jqtree.
Thanks, @mbraak :)
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.