Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kanety/jquery-simple-tree


https://github.com/kanety/jquery-simple-tree

Last synced: 8 days ago
JSON representation

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).