Skip to content

Commit

Permalink
Merge pull request #61 from pjona/patch-4
Browse files Browse the repository at this point in the history
Added new functions to README.md, and update ChangeLog
  • Loading branch information
RamonSmit authored May 22, 2017
2 parents 8ff53ed + 2f2d627 commit c7eaeb5
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can install this package either with `npm` or with `bower`.
### npm

```shell
npm install nestable2
npm install --save nestable2
```

Then add a `<script>` to your `index.html`:
Expand All @@ -36,7 +36,7 @@ Or `require('nestable2')` from your code.
### bower

```shell
bower install nestable2
bower install --save nestable2
```

## Usage
Expand Down Expand Up @@ -138,10 +138,35 @@ The serialised JSON for the example above would be:
```json
[{"id":1},{"id":2},{"id":3,"children":[{"id":4},{"id":5,"foo":"bar"}]}]
```

`toArray`:
```js
$('.dd').nestable('toArray');
```
Builds an array where each element looks like:
```json
{
'depth': depth',
'id': id,
'left': left,
'parent_id': parentId || null,
'right': right
}
```

You can get a hierarchical nested set model like below.
```js
$('.dd').nestable('asNestedSet');
```
The output will be like below:
```js
[{"id":1,"parent_id":"","depth":0,"lft":1,"rgt":2},{"id":2,"parent_id":"","depth":0,"lft":3,"rgt":4},{"id":3,"parent_id":"","depth":0,"lft":5,"rgt":10},{"id":4,"parent_id":3,"depth":1,"lft":6,"rgt":7},{"id":5,"parent_id":3,"depth":1,"lft":8,"rgt":9}]
```

`destroy`:
You can deactivate the plugin by running
```js
$('.dd').nestable('destroy');
$('.dd').nestable('destroy');
```


Expand Down Expand Up @@ -237,12 +262,33 @@ These advanced config options are also available:

## Change Log

### 22th May 2017

* [pjona] Added npm installation

### 10th April 2017

* [timalennon] Added functions: `toHierarchy` and `toArray`

### 17th November 2015

* [oimken] Added `destroy` function

### 2nd November 2015

* [ivanbarlog] Added `onDragStart` event fired when user starts to drag an element

### 21th April 2015

* [ozdemirburak] Added `asNestedSet` function
* [ozdemirburak] Added bower installation

### 6th October 2014

* [zemistr] Created listRenderer and itemRenderer. Refactored build from JSON.
* [zemistr] Added support for adding classes via input data. (```[{"id": 1, "content": "First item", "classes": ["dd-nochildren", "dd-nodrag", ...] }, ... ]```)

### 3th October 2014
### 3rd October 2014

* [zemistr] Added support for additional data parameters.
* [zemistr] Added callback for customizing content.
Expand Down

0 comments on commit c7eaeb5

Please sign in to comment.