Skip to content

Commit

Permalink
Merge pull request #8 from cristinawithout/destroy-event
Browse files Browse the repository at this point in the history
Destroy jstree on willDestroyElement. Send eventDidDestroy.
  • Loading branch information
ritesh83 committed Apr 17, 2015
2 parents 781de32 + 18d2dd2 commit 8774002
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ in your controller.

The following events have basic support included. More are on the way.

| jsTree Event | Ember Action |
|----------------|---------------------|
| changed.jstree | eventDidChange |
| init.jstree | eventDidInit |
| ready.jstree | eventDidBecomeReady |
| redraw.jstree | eventDidRedraw |
| jsTree Event | Ember Action |
|------------------------|-----------------------|
| changed.jstree | eventDidChange |
| init.jstree | eventDidInit |
| ready.jstree | eventDidBecomeReady |
| redraw.jstree | eventDidRedraw |
| (destroyed - no event) | eventDidDestroy |

**Note:** In the meantime, you can add event listeners yourself by calling them on a mapped `treeObject` property.

Expand Down
6 changes: 5 additions & 1 deletion addon/components/ember-jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default Ember.Component.extend(InboundActions, EmberJstreeActions, {
this.set('treeObject', treeObject);
},

willDestroyElement: function() {
this.send('destroy');
},

searchCallback: function(str, node) {
if(typeof node.original === 'object') {
if(node.original[this.search_property]) {
Expand Down Expand Up @@ -110,7 +114,7 @@ export default Ember.Component.extend(InboundActions, EmberJstreeActions, {
_setupContextMenus: function(pluginsArray) {
var contextmenuOptions = this.get('contextmenuOptions');
var self = this;

if (null === pluginsArray) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions addon/mixins/ember-jstree-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default Ember.Mixin.create({
var o = this.get('treeObject');
if (null !== o) {
o.jstree(true).destroy();
this.sendAction('eventDidDestroy');
}
},

Expand Down

0 comments on commit 8774002

Please sign in to comment.