Confirm
Asks a question and resolves to a boolean answer.
When to use
- Confirm a consequential action before applying it.
Examples
Ask for confirmation
Loading the example
<k:Button text="Discard the draft" press=".onConfirm"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast", "kor/ui/Confirm"], (Controller, Toast, Confirm) => Controller.extend("sample.AskConfirm", {
async onConfirm() {
const approved = await Confirm.ask({ title: "Discard the draft?" });
Toast.show(approved ? "Confirmed" : "Cancelled");
}
}));Require a record code
Loading the example
<k:Button text="Remove shipment" press=".onConfirm"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast", "kor/ui/Confirm"], (Controller, Toast, Confirm) => Controller.extend("sample.AskConfirm", {
async onConfirm() {
const approved = await Confirm.ask({
title: "Remove shipment SH-104?",
text: "The dispatch list will no longer show this shipment.",
danger: true,
type: "SH-104"
});
Toast.show(approved ? "Confirmed" : "Cancelled");
}
}));API
Methods
| Name | Description |
|---|---|
ask(options: ConfirmOptions): Promise<boolean> | Resolves to true when the user confirms, or false when they cancel or dismiss |
type ConfirmOptions = {
title: string;
text?: string;
confirmText?: string;
cancelText?: string;
danger?: boolean;
/** Verilirse kullanıcı bunu yazmadan onaylayamaz */
type?: string;
};