mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
toggle: Add register_event_handlers to toggle prototype.
This is a preparatory commit to combine user settings panels into one. We need to re-register event handlers since they get destroyed when the settings modal is closed. After re-opening the modal, clicking the tabs would not do anything unless we re-register our event handlers.
This commit is contained in:
committed by
Tim Abbott
parent
78630b6395
commit
dd4fc4285a
@@ -23,6 +23,7 @@ export type Toggle = {
|
||||
value: () => string | undefined;
|
||||
get: () => JQuery;
|
||||
goto: (name: string) => void;
|
||||
register_event_handlers: () => void;
|
||||
};
|
||||
|
||||
export function toggle(opts: {
|
||||
@@ -115,10 +116,14 @@ export function toggle(opts: {
|
||||
return false;
|
||||
}
|
||||
|
||||
meta.$ind_tab.on("click", function () {
|
||||
const idx = Number($(this).attr("data-tab-id"));
|
||||
select_tab(idx);
|
||||
});
|
||||
function register_event_handlers(): void {
|
||||
meta.$ind_tab.off("click");
|
||||
meta.$ind_tab.on("click", function () {
|
||||
const idx = Number($(this).attr("data-tab-id"));
|
||||
select_tab(idx);
|
||||
});
|
||||
}
|
||||
register_event_handlers();
|
||||
|
||||
keydown_util.handle({
|
||||
$elem: meta.$ind_tab,
|
||||
@@ -186,6 +191,8 @@ export function toggle(opts: {
|
||||
select_tab(idx);
|
||||
}
|
||||
},
|
||||
|
||||
register_event_handlers,
|
||||
};
|
||||
|
||||
return prototype;
|
||||
|
||||
Reference in New Issue
Block a user