Skip to content

Commit

Permalink
Fix for detach previously events (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkit committed Nov 29, 2016
1 parent 46cb735 commit 0b7379e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/Select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class Select2 extends Component {

const handlerChanged = e => prevProps[e[1]] !== props[e[1]];
if (props.events.some(handlerChanged)) {
this.detachEventHandlers(props);
this.detachEventHandlers();
this.attachEventHandlers(props);
}
}
Expand All @@ -111,7 +111,7 @@ export default class Select2 extends Component {

destroySelect2(withCallbacks = true) {
if (withCallbacks) {
this.detachEventHandlers(this.props);
this.detachEventHandlers();
}

this.el.select2('destroy');
Expand All @@ -126,9 +126,9 @@ export default class Select2 extends Component {
});
}

detachEventHandlers(props) {
props.events.forEach(event => {
if (typeof props[event[1]] !== 'undefined') {
detachEventHandlers() {
this.props.events.forEach(event => {
if (typeof this.props[event[1]] !== 'undefined') {
this.el.off(event[0]);
}
});
Expand Down

0 comments on commit 0b7379e

Please sign in to comment.