Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 966e402

Browse files
committed
Fix for duplicate events being fired when re-initializing tree #4
1 parent 38f3c7e commit 966e402

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

dist/bootstrap-treeview.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/bootstrap-treeview.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
_unsubscribeEvents: function() {
112112

113113
this.$element.off('click');
114+
115+
if (typeof (this.options.onNodeSelected) === 'function') {
116+
this.$element.off('nodeSelected');
117+
}
114118
},
115119

116120
_subscribeEvents: function() {

src/js/bootstrap-treeview.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
_unsubscribeEvents: function() {
112112

113113
this.$element.off('click');
114+
115+
if (typeof (this.options.onNodeSelected) === 'function') {
116+
this.$element.off('nodeSelected');
117+
}
114118
},
115119

116120
_subscribeEvents: function() {

tests/lib/bootstrap-treeview.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
_unsubscribeEvents: function() {
112112

113113
this.$element.off('click');
114+
115+
if (typeof (this.options.onNodeSelected) === 'function') {
116+
this.$element.off('nodeSelected');
117+
}
114118
},
115119

116120
_subscribeEvents: function() {

0 commit comments

Comments
 (0)