Ask the user to confirm. Pass a bare string for the simplest case, or an options bag for control over title/type/labels/detail.
a Promise resolving true if confirmed, false otherwise.
Convenience for destructive deletes — type: 'danger' and a 'Delete'
confirm label by default (both overridable via options).
MJConfirmService — Imperative, Promise-based confirmation prompts.
The one-liner replacement for native
window.confirm()(an anti-pattern this codebase bans) and for the boilerplate of wiring<mj-confirm-dialog>into a template just to ask a yes/no question. It dynamically mounts anMJConfirmDialogComponenttodocument.body, shows it, and resolves aPromise<boolean>—trueon confirm,falseon cancel/backdrop/Esc — then tears the component down.Example
Async work after confirm: because this resolves a boolean, the dialog has already closed by the time your
awaitcontinues — there's no in-dialog spinner. When you need a "keep open + spinner while I save" UX, use the<mj-confirm-dialog>component directly with itsProcessinginput instead.Synchronous guards:
window.confirmblocks the thread; a synchronousCanClose/beforeunloadguard that must return a boolean immediately cannot use this async service. Those rare cases stay onwindow.confirmas a documented exception.