template::add_body_handler (public)

 template::add_body_handler -event event -script script \
    [ -identifier identifier ]

Defined in packages/acs-templating/tcl/head-procs.tcl

Adds JavaScript code to an event handler in the body tag. Several JavaScript code blocks may be assigned to each handler by subsequent calls to template::add_body_handler.

If your script may only be added once you may supply an identifier. Subsequent calls to template::add_body_handler with the same identifier will replace your script rather than appending to it.

event may be one of:

  • onload
  • onunload
  • onclick
  • ondblclick
  • onmousedown
  • onmouseup
  • onmouseover
  • onmousemove
  • onmouseout
  • onkeypress
  • onkeydown
  • onkeyup

Switches:
-event (required)
the event during which the supplied script should be executed
-script (required)
the JavaScript code to execute
-identifier (optional, defaults to "anonymous")
a name, if supplied, used to ensure this JavaScript code is only added to the handler once

Partial Call Graph (max 5 caller/called nodes):
%3 test_templates_and_scripts templates_and_scripts (test acs-templating) template::add_body_handler template::add_body_handler test_templates_and_scripts->template::add_body_handler Class ::xo::lti::LTI Class ::xo::lti::LTI (public) Class ::xo::lti::LTI->template::add_body_handler Class ::xowiki::formfield::richtext::tinymce Class ::xowiki::formfield::richtext::tinymce (public) Class ::xowiki::formfield::richtext::tinymce->template::add_body_handler packages/acs-templating/www/scripts/xinha/attach-file.tcl packages/acs-templating/ www/scripts/xinha/attach-file.tcl packages/acs-templating/www/scripts/xinha/attach-file.tcl->template::add_body_handler packages/acs-templating/www/scripts/xinha/attach-image.tcl packages/acs-templating/ www/scripts/xinha/attach-image.tcl packages/acs-templating/www/scripts/xinha/attach-image.tcl->template::add_body_handler packages/calendar/www/cal-item-new.tcl packages/calendar/ www/cal-item-new.tcl packages/calendar/www/cal-item-new.tcl->template::add_body_handler

Testcases:
templates_and_scripts
Source code:
    variable ::template::body_handlers

    if {$identifier eq "anonymous"} {
        lappend body_handlers($event,anonymous) $script
    } else {
        # Even a one event handler needs to be added in a list
        # since all handlers, anonymous and specific are treated as a
        # list in blank-master.tcl
        set body_handlers($event,$identifier) [list $script]
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: