Skip to content

Commit

Permalink
fix binding of confirmable actions loaded after initial page
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 16, 2024
1 parent 68f8b1c commit 8f1bfc9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions ui/site/src/domHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ export function attachDomHandlers() {
else $(this).one('focus', start);
});

$('.yes-no-confirm, .ok-cancel-confirm').on('click', async function (this: HTMLElement, e: Event) {
if (!e.isTrusted) return;
e.preventDefault();
const [confirmText, cancelText] = this.classList.contains('yes-no-confirm')
? [i18n.site.yes, i18n.site.no]
: [i18n.site.ok, i18n.site.cancel];
if (await confirm(this.title || 'Confirm this action?', confirmText, cancelText))
(e.target as HTMLElement)?.click();
});
$('#main-wrap').on(
'click',
'.yes-no-confirm, .ok-cancel-confirm',
async function (this: HTMLElement, e: Event) {
if (!e.isTrusted) return;
e.preventDefault();
const [confirmText, cancelText] = this.classList.contains('yes-no-confirm')
? [i18n.site.yes, i18n.site.no]
: [i18n.site.ok, i18n.site.cancel];
if (await confirm(this.title || 'Confirm this action?', confirmText, cancelText))
(e.target as HTMLElement)?.click();
},
);

$('#main-wrap').on('click', 'a.bookmark', function (this: HTMLAnchorElement) {
const t = $(this).toggleClass('bookmarked');
Expand Down

0 comments on commit 8f1bfc9

Please sign in to comment.