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
(defaults to "click") (optional)
register confirm handler for this type of event
-message
(defaults to "#acs-templating.Are_you_sure#") (optional)
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
(defaults to "acs-confirm") (optional)
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):
%3 test_templates_and_scripts templates_and_scripts (test acs-templating) template::add_confirm_handler template::add_confirm_handler test_templates_and_scripts->template::add_confirm_handler _ _ (public) template::add_confirm_handler->_ Class ::Generic::List Class ::Generic::List (public) Class ::Generic::List->template::add_confirm_handler packages/acs-admin/www/auth/authority.tcl packages/acs-admin/ www/auth/authority.tcl packages/acs-admin/www/auth/authority.tcl->template::add_confirm_handler packages/acs-admin/www/auth/index.tcl packages/acs-admin/ www/auth/index.tcl packages/acs-admin/www/auth/index.tcl->template::add_confirm_handler packages/acs-automated-testing/www/server.tcl packages/acs-automated-testing/ www/server.tcl packages/acs-automated-testing/www/server.tcl->template::add_confirm_handler packages/acs-lang/www/admin/index.tcl packages/acs-lang/ www/admin/index.tcl packages/acs-lang/www/admin/index.tcl->template::add_confirm_handler

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
    }

    {*}$cmd
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: