template::add_confirm_handler (public)
template::add_confirm_handler [ -event event ] [ -message message ] \ [ -CSSclass CSSclass ] [ -id id ] [ -selector selector ] \ [ -formfield formfield ]
Defined in packages/acs-templating/tcl/head-procs.tcl
Register an event handler for confirmation dialogs for elements either with a specified ID, CSS class, a formfield targeted by form id and field name or a CSS selector.
- Switches:
- -event (optional, defaults to
"click"
)- register confirm handler for this type of event
- -message (optional, defaults to
"#acs-templating.Are_you_sure#"
)- Message to be displayed in the confirmation dialog. If the message looks like a message key (starting and ending with a hash sign) it is treated as a message key
- -CSSclass (optional, defaults to
"acs-confirm"
)- register confirm handler for this CSS class
- -id (optional)
- register confirm handler for this HTML ID
- -selector (optional)
- register confirm handler for elements identified by this CSS selector. When a CSS selector contains double and single quotes, we won't add any of those around the selector automatically. Instead, the user must specify them explicitly, for instance like this: ... -selector {'[name="o\'hara"]'}. If the selector does not contain any single or double quotes, we can let the user omit them, as for the case of a simple tag name selector: ... -selector "li". Quotes can also be omitted if the selector contains only one kind of them, like ... -selector {[data-property='value']} or ... -selector {[data-property="value"]}
- -formfield (optional)
- register confirm handler for this formfield, specified in a list of two elements in the form
{ form_id field_name }
- Author:
- Gustaf Neumann
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- templates_and_scripts
Source code: if {[regexp {^#(.*)*#$} $message . key]} { set message [_ $key] } set script [subst { if (!confirm(`$message`)) { event.preventDefault(); } }] set cmd [list template::add_event_listener -event $event -script $script -preventdefault=false] if {[info exists id]} { lappend cmd -id $id } elseif {[info exists formfield]} { lappend cmd -formfield $formfield } elseif {[info exists selector]} { lappend cmd -selector $selector } else { lappend cmd -CSSclass $CSSclass } {*}$cmdXQL Not present: Generic, PostgreSQL, Oracle