https://github.com/tmcw/treeui
A simple collapsible tree ui, for file selectors and the like.
https://github.com/tmcw/treeui
Last synced: about 1 year ago
JSON representation
A simple collapsible tree ui, for file selectors and the like.
- Host: GitHub
- URL: https://github.com/tmcw/treeui
- Owner: tmcw
- Created: 2014-03-28T20:08:16.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-10T21:33:27.000Z (over 9 years ago)
- Last Synced: 2025-07-10T12:53:16.138Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# treeui
A simple collapsible tree ui, for file selectors and the like.
## install
npm install --save treeui
## example
[Live example on requirebin](http://requirebin.com/?gist=tmcw/9842067)
```js
var treeui = require('treeui');
treeui(request)
.onclick(function(level) {
console.log(level);
})
.appendTo(document.body);
function request(tree, callback) {
callback(null, [1 + tree, 2 + tree, 3 + tree]);
}
```
## api
### treeui(request)
Request is a function that takes `(level, callback)` and calls callback
with `(err, results)`, where results is an array.
### onclick(callback)
Call callback with the tree level of clicked items
## appendTo(elem)
Append the UI to a given DOM element.