template::add_event_listener (public)
template::add_event_listener [ -event event ] [ -CSSclass CSSclass ] \ [ -id id ] [ -formfield formfield ] [ -selector selector ] \ [ -usecapture ] [ -preventdefault ] -script script
Defined in packages/acs-templating/tcl/head-procs.tcl
Register an event handler for elements. The affected elements can be specified in different ways, which will be checked in the following order of precedence: id, formfield, selector and CSSclass. Normally one needs to provide only one kind of specification.
- Switches:
- -event (optional, defaults to
"click"
)- register handler for this type of event
- -CSSclass (optional, defaults to
"acs-listen"
)- register handler for this CSS class
- -id (optional)
- register handler for this HTML ID
- -formfield (optional)
- register handler for this formfield, specified in a list of two elements in the form
{ form_id field_name }
- -selector (optional)
- register 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"]}
- -usecapture (optional, boolean, defaults to
"false"
)- indicating whether event will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree.
- -preventdefault (optional, boolean, defaults to
"true"
)- this option can the used prevent default click handling
- -script (required)
- Author:
- Gustaf Neumann
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- templates_and_scripts