confirm

See also

actions alert and growl.

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

Example:

{% button action={confirm
                  text="Format hard disk?"
                  ok="Go Ahead!"
                  action={growl text="Better not"}
                  is_danger}
%}

Shows a JavaScript dialog with the question “Format hard disk?”. If this dialog is confirmed then the growl message “Better not” will appear. If the dialog is denied or canceled then nothing happens.

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

event(#postback{message=Message, trigger=TriggerId, target=TargetId}, Context).

Confirm accepts the following arguments:

ArgumentDescriptionExample
textThe text to be displayed.text=_”The answer to life and the rest?”
titleTitle above the alert, defaults to _"Confirm"title=_”Rescue the world, with an answer”
okThe text of the ok button, defaults to _"OK"text=”42”
cancelThe text of the cancel button, defaults to _"Cancel"text=”No, thanks for the fish”
text_templateTemplate used to render the text, all action arguments are passed to the template.text_template=”_fancy_confirm.tpl”
actionOne or more actions to be executed on confirmation. This argument can be repeated.action=\{alert text=”you said ok”\}
on_cancelOne or more actions to be executed on cancelationon_cancel=\{alert text=”you said cancel”\}
postbackEvent to be sent back to the server if the ok button is clicked.postback=”clicked_confirm”
delegateErlang module handling the postback. Defaults to the controller generating the page.delegate=”my_event_module”
is_dangerIf the ‘ok’ button should be flagged as dangerous.is_danger
levelNesting of the dialog. Non negative integer, higher numbered levels are displayed above lower levels. Special level "top" to force display on top.level=”top”

Edit on GitHub