Go to page content

confirm

Show javascript confirm.

Show a javascript confirm message and on confirmation triggers one or more actions and/or send a postback to the server.

Example:

{% button action={confirm text="Format hard disk?" action={growl text="Better not"}} %}

Shows a javascript dialog with the question "Format hard disk?".  When this dialog is confirmed then the growl message "Better not" will appear. When the dialog is denied or canceled then nothing happens.

When there is a postback defined then the event handler for the postback will be called like:

event({postback, Postback, TriggerId, TargetId}, Context).

Confirm accepts the following arguments:

ArgumentDescriptionExample
textThe text to be displayed.text="Hola!"
actionOne or more actions to be executed on confirmation. This argument can be repeated.action={alert text="plop"}
postbackEvent to be sent back to the server.postback="clicked_confirm"
delegateErlang module handling the postback. Defaults to the resource generating the page.delegate="my_event_module"

See also the actions alert and growl.

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.

Comments

  • avatar

    jeff

    Posted 1 year, 5 months ago.

    In the example above there is a missing closing } for the main action event.

    {% button action={confirm text="Format hard disk?" action={growl text="Better not"} %}

    should read

    {% button action={confirm text="Format hard disk?" action={growl text="Better not"}} %}

  • avatar

    Marc Worrell

    Posted 1 year, 5 months ago.

    Thanks, fixed!

  • avatar

    Andreas Stenius

    Posted 3 months, 3 days ago.

    The args table is out-of-date.

    The following args are notably interesting:

    title, text_template, ok and cancel. (the last two for setting the button caption for the two buttons.)

  • avatar

    Andreas Stenius

    Posted 3 months, 3 days ago.

    Ah, and the on_cancel action(s).