Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weisjohn/jquery-tree-manipulator
A depth-first walker for manipulating an arbitrary DOM tree.
https://github.com/weisjohn/jquery-tree-manipulator
Last synced: about 1 month ago
JSON representation
A depth-first walker for manipulating an arbitrary DOM tree.
- Host: GitHub
- URL: https://github.com/weisjohn/jquery-tree-manipulator
- Owner: weisjohn
- License: mit
- Created: 2014-03-24T17:59:45.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-05T06:54:09.000Z (almost 10 years ago)
- Last Synced: 2024-11-09T16:58:56.472Z (about 2 months ago)
- Homepage: http://weisjohn.github.io/jquery-tree-manipulator/
- Size: 168 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
jquery-tree-manipulator
=============a depth-first walker for manipulating an arbitrary DOM tree
`jquery-tree-manipulator` was born out of a need to integrate with http://blog.yesmeck.com/jquery-jsonview/ without rebuilding the whole thing.
[Demo](http://weisjohn.github.io/jquery-tree-manipulator/)
### usage
`sample.html`:
```html
foo
-
bar
- bat
- baz
- bin
-
- cat
````sample.js`:
```javascript
$(".tree").treeManipulator({
structure: "> ul > li",
opened: ".collapser:contains('-')",
closed: ".collapser:contains('+')"
});
````jquery-tree-manipulator` requires you tell it how to traverse your tree. You must provide three selectors for it to know how to traverse, open, and close the DOM nodes.
You can then invoke the `close` and `open` methods on the plugin, optionally passing a `depth` limit as an argument, such as:
```javascript
// close all nodes
$(".tree").treeManipulator('close');
// open the first level
$(".tree").treeManipulator('open', 1);
```