Skip to content

Commit

Permalink
Register unique clickOutSideToClose click handlers
Browse files Browse the repository at this point in the history
Prevents removal of the wrong listener when multiple dialogs are on the same page.
  • Loading branch information
oscarni committed May 17, 2016
1 parent ccf27b3 commit ecd7f45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addon/components/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export default Ember.Component.extend({
this.send('close');
}
};
const registerClick = () => $(document).on('click.ember-modal-dialog', handleClick);
const registerClick = () => $(document).on('click.ember-modal-dialog' + this.get('elementId'), handleClick);

// setTimeout needed or else the click handler will catch the click that spawned this modal dialog
setTimeout(registerClick);
this._super(...arguments);
},
willDestroyElement() {
$(document).off('click.ember-modal-dialog');
$(document).off('click.ember-modal-dialog' + this.get('elementId'));
this._super(...arguments);
},

Expand Down

0 comments on commit ecd7f45

Please sign in to comment.