bootstrap-vue
Version:
BootstrapVue provides one of the most comprehensive implementations of Bootstrap 4 components and grid system for Vue.js and with extensive and automated WAI-ARIA accessibility markup.
22 lines (21 loc) • 581 B
JavaScript
export default {
mounted: function mounted() {
if (typeof document !== 'undefined') {
document.documentElement.addEventListener('click', this._clickOutListener);
}
},
beforeDestroy: function beforeDestroy() {
if (typeof document !== 'undefined') {
document.documentElement.removeEventListener('click', this._clickOutListener);
}
},
methods: {
_clickOutListener: function _clickOutListener(e) {
if (!this.$el.contains(e.target)) {
if (this.clickOutListener) {
this.clickOutListener();
}
}
}
}
};