Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/jquery-simple-tree
https://github.com/kanety/jquery-simple-tree
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanety/jquery-simple-tree
- Owner: kanety
- License: mit
- Created: 2018-12-23T11:11:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-23T02:01:06.000Z (almost 4 years ago)
- Last Synced: 2024-12-25T04:04:43.999Z (23 days ago)
- Language: JavaScript
- Size: 46.9 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jquery-simple-tree
A jquery plugin for simple tree ui.
## Dependencies
* jquery
## Installation
Install from npm:
$ npm install @kanety/jquery-simple-tree --save
## Usage
Build tree using list elements as follows:
```html
-
text of 1
-
text of 1.1
-
text of 1.1.1
-
text of 1.1.2
-
-
```
Then run:
```javascript
$('#tree').simpleTree();
```
### Options
Specify opened nodes:
```javascript
$('#tree').simpleTree({
opened: [1, 1.1]
});
```
Save node state to `sessionStorage` or `localStorage`:
```javascript
$('#tree').simpleTree({
store: 'session', // or 'local'
storeKey: 'YOUR_KEY'
});
```
### Callbacks
Run callbacks when a node is opened or closed:
```javascript
$('#tree').simpleTree({
...
}).on('node:open', function(e, $node) {
...
}).on('node:close', function(e, $node) {
...
});
```
### Functions
Manipulate nodes from your script:
```javascript
var tree = $('#tree').data('simple-tree'); // get SimpleTree instance
tree.openByID(1);
tree.closeByID(1);
```
## License
The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).