10 examples of 'bootstrap dropdown close on click outside' in JavaScript

Every line of 'bootstrap dropdown close on click outside' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
62private onClicked(event: any) {
63
64 event.preventDefault();
65
66 if (!this.click || this.disabled) {
67 return;
68 }
69
70 if (this.task) {
71 return;
72 }
73
74 this.isBusy = true;
75
76 this.task = Promise.resolve(this.click({ event: event, target: this.element }))
77 .then(
78 () => this.clickCompleted(),
79 () => this.clickCompleted()
80 );
81}
119closeDropdown() {
120 // Don't use ng-class here, it could cause issue on positionning.
121 this.isDropdownOpen = false;
122 this.destroyPopper();
123
124 this.$document.off('click', this.documentClickHandler);
125
126 // Update trigger
127 if (this.triggerCtrl.afterClose) {
128 this.triggerCtrl.afterClose();
129 }
130}
81function closeDropdownFn() {
82 jqLite.removeClass(menuEl, openClass);
83
84 // remove event handlers
85 jqLite.off(doc, 'click', closeDropdownFn);
86}
54close() {
55 this.$broadcast('dropdown-list::close');
56}
76function closeDropdown () {
77 Dropdown.componentInstance.hide()
78}
19async close(dropdown: ElementFinder) {
20 await dropdown.$(`button[ngbDropdownToggle]`).click();
21 expect(await this.isOpened(dropdown)).toBeFalsy(`Dropdown should have been closed`);
22}
76function closeDropdownFn() {
77 jqLite.removeClass(menuEl, openClass);
78
79 // remove event handlers
80 jqLite.off(doc, 'click', closeDropdownFn);
81 jqLite.off(doc, 'keydown', handleKeyDownFn);
82}
26closeDropDown() {
27 this.item.find(".dropdown-content").removeClass('show');
28 $(window).off('click', this.dropWatch);
29}
584closeDropdown: function closeDropdown() {
585 var _this3 = this;
586
587 if (this.showDropdown) {
588 this.$nextTick(function () {
589 _this3.showDropdown = false;
590 _this3.highlightedIndex = -1;
591 _this3.$emit('dropdown-close');
592 });
593 }
594},
61set closeOnOutsideClick(closeOnOutsideClick: boolean) {
62 this._closeOnOutsideClick = coerceBooleanProperty(closeOnOutsideClick);
63}

Related snippets