> For the complete documentation index, see [llms.txt](https://cbwire.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cbwire.ortusbooks.com/template-directives/wire-confirm.md).

# wire:confirm

The `wire:confirm` directive adds a confirmation dialog before executing actions, protecting users from accidental clicks on destructive operations. When users click an element with `wire:confirm`, they'll see a browser confirmation dialog that must be accepted before the action proceeds.

## Basic Usage

This subscription management component demonstrates `wire:confirm` for protecting critical actions:

{% tabs %}
{% tab title="BoxLang" %}

```javascript
// wires/SubscriptionManager.bx
class extends="cbwire.models.Component" {
    data = {
        "subscriptionActive": true,
        "userName": "John Doe"
    };

    function cancelSubscription() {
        data.subscriptionActive = false;
    }

    function deleteAccount() {
        // Permanently delete account logic
        redirect("/goodbye");
    }
}
```

{% endtab %}

{% tab title="CFML" %}

```javascript
// wires/SubscriptionManager.cfc
component extends="cbwire.models.Component" {
    data = {
        "subscriptionActive" = true,
        "userName" = "John Doe"
    };

    function cancelSubscription() {
        data.subscriptionActive = false;
    }

    function deleteAccount() {
        // Permanently delete account logic
        redirect("/goodbye");
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="BoxLang" %}

```html
<!-- wires/subscriptionManager.bxm -->
<bx:output>
<div>
    <h1>Account Settings</h1>
    
    <button wire:click="cancelSubscription" 
            wire:confirm="Are you sure you want to cancel your subscription?">
        Cancel Subscription
    </button>
    
    <button wire:click="deleteAccount" 
            wire:confirm.prompt="Please confirm deletion by typing 'DELETE' below|DELETE">
        Delete Account
    </button>
</div>
</bx:output>
```

{% endtab %}

{% tab title="CFML" %}

```html
<!-- wires/subscriptionManager.cfm -->
<cfoutput>
<div>
    <h1>Account Settings</h1>
    
    <button wire:click="cancelSubscription" 
            wire:confirm="Are you sure you want to cancel your subscription?">
        Cancel Subscription
    </button>
    
    <button wire:click="deleteAccount" 
            wire:confirm.prompt="Please confirm deletion by typing 'DELETE' below|DELETE">
        Delete Account
    </button>
</div>
</cfoutput>
```

{% endtab %}
{% endtabs %}

## What wire:confirm Does

When you add `wire:confirm` to an element, CBWIRE automatically:

* **Shows Confirmation Dialog**: Displays a browser confirmation dialog with your custom message
* **Blocks Action Execution**: Prevents the action from running if the user cancels
* **Continues on Accept**: Executes the action normally if the user confirms
* **Integrates with Actions**: Works seamlessly with any `wire:click` action

## Available Modifiers

The `wire:confirm` directive supports one modifier:

* **Prompt**: `.prompt` - Requires users to type a specific confirmation text

Example: `wire:confirm.prompt="Type DELETE to confirm|DELETE"`

{% hint style="info" %}
Use `wire:confirm` on any destructive or irreversible actions to prevent accidental data loss and improve user experience.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cbwire.ortusbooks.com/template-directives/wire-confirm.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
