Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

overlays: Add `autoremove` option to `open_modal`.

Ganesh Pawar0b769bfcc87d
diff --git a/static/js/overlays.js b/static/js/overlays.js
index de43f697e20..4e84c826cd2 100644
--- a/static/js/overlays.js
+++ b/static/js/overlays.js
@@ -111,7 +111,9 @@ export function open_overlay(opts) {
};
}
-export function open_modal(selector) {
+// If autoremove is true, the modal element will be removed from the DOM
+// once the modal is hidden.
+export function open_modal(selector, autoremove = false) {
if (selector === undefined) {
blueslip.error("Undefined selector was passed into open_modal");
return;
@@ -136,6 +138,12 @@ export function open_modal(selector) {
// Remove previous alert messages from modal, if exists.
elem.find(".alert").hide();
elem.find(".alert-notification").html("");
+
+ if (autoremove) {
+ elem.on("hidden.bs.modal", () => {
+ elem.remove();
+ });
+ }
}
export function close_overlay(name) {