template::get_body_event_handlers (public)
template::get_body_event_handlers
Defined in packages/acs-templating/tcl/head-procs.tcl
Get body event handlers specified with template::add_body_handler. The proc clears the global variable ::template::body_handlers after having processed its content.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- templates_and_scripts
Source code: template::register_double_click_handler # # Concatenate the JavaScript event handlers for the body tag # variable ::template::body_handlers set event_handlers "" if {[array exists body_handlers]} { # # Collect all entries for one event type (e.g. "onload") # foreach name [array names body_handlers] { set event [lindex [split $name ","] 0] foreach js $body_handlers($name) { lappend body_handlers($event) "[string trimright $js {; }];" } unset body_handlers($name) } # # Turn events into calls for event listener and add these via # add_body_script. # set js "" foreach {event script} [array get body_handlers] { # # Remove the "on" prefix if provided. E.g. "onload" is # mapped to the "load" event on "window" (UIevent). It # would as well be possible to map to DOM events (on # "document") # (https://developer.mozilla.org/en-US/docs/Web/Events) # regsub ^on $event "" event append js [ns_trim -delimiter | [subst { | window.addEventListener('$event', function () { | [join $script { }] | }, false); |}]] } if {$js ne ""} { template::add_body_script -script $js } unset body_handlers } return $event_handlersXQL Not present: Generic, PostgreSQL, Oracle