Skip to main content

onconfirm

Description

Fires when a non-cancel button is clicked or when the ENTER key is pressed

Usage

onconfirm?: (ev: { button?: string; ev: MouseEvent }) => void;

Parameters

The callback of the event can receive:

  • button – (optional) the id of the button that was clicked. It will be set to "ok" for the OK button, or the configured id of any other custom button (except "cancel"). If the event fires by pressing ENTER, the callback is called with no parameters.

  • ev – (required) the native click event of the button

Example

<script>
import { Modal, Text, Portal, Button } from "@svar-ui/svelte-core";

let custom1;
function hideAll() {
custom1 = false;
}
</script>

{#if custom1}
<Portal>
<Modal title="Custom Prompt" onconfirm={hideAll}>
<Text select={true} focus={true} value="Some" />
</Modal>
</Portal>
{/if}

Related article: Providing the buttons' functionality

Related sample: Messages