Moodle PHP Documentation 4.5
Moodle 4.5.5+ (Build: 20250711) (ce34e8ff087)
core\output\js_writer Class Reference

Static Public Member Functions

static event_handler ($selector, $event, $function, ?array $arguments=null)
 Writes event handler attaching code.
 
static function_call ($function, ?array $arguments=null, $delay=0)
 Returns javascript code calling the function.
 
static function_call_with_y ($function, ?array $extraarguments=null)
 Special function which adds Y as first argument of function call.
 
static object_init ($var, $class, ?array $arguments=null, ?array $requirements=null, $delay=0)
 Returns JavaScript code to initialise a new object.
 
static set_variable ($name, $value, $usevar=true)
 Returns code setting value to variable.
 

Member Function Documentation

◆ event_handler()

static core\output\js_writer::event_handler ( $selector,
$event,
$function,
?array $arguments = null )
static

Writes event handler attaching code.

Parameters
array | string$selectorstandard YUI selector for elements, may be array or string, element id is in the form "#idvalue"
string$eventA valid DOM event (click, mousedown, change etc.)
string$functionThe name of the function to call
null | array$argumentsAn optional array of argument parameters to pass to the function
Return values
stringJS code fragment

◆ function_call()

static core\output\js_writer::function_call ( $function,
?array $arguments = null,
$delay = 0 )
static

Returns javascript code calling the function.

Parameters
string$functionfunction name, can be complex like Y.Event.purgeElement
null | array$argumentsparameters
int$delayexecution delay in seconds
Return values
stringJS code fragment

◆ function_call_with_y()

static core\output\js_writer::function_call_with_y ( $function,
?array $extraarguments = null )
static

Special function which adds Y as first argument of function call.

Parameters
string$functionThe function to call
null | array$extraargumentsAny arguments to pass to it
Return values
stringSome JS code

◆ object_init()

static core\output\js_writer::object_init ( $var,
$class,
?array $arguments = null,
?array $requirements = null,
$delay = 0 )
static

Returns JavaScript code to initialise a new object.

Parameters
string$varIf it is null then no var is assigned the new object.
string$classThe class to initialise an object for.
null | array$argumentsAn array of args to pass to the init method.
null | array$requirementsAny modules required for this class.
int$delayThe delay before initialisation. 0 = no delay.
Return values
stringSome JS code

◆ set_variable()

static core\output\js_writer::set_variable ( $name,
$value,
$usevar = true )
static

Returns code setting value to variable.

Parameters
string$name
mixed$valuejson serialised value
bool$usevaradd var definition, ignored for nested properties
Return values
stringJS code fragment

The documentation for this class was generated from the following file: