Name

method — Attaches a function or event handler to an object or class.

Synopsis

LZX: method
Type: Class
Access: public
Topic: LZX.Basics

Description

Attaches a method to the object that contains this element. The method must have a name.

The name attribute allows the method to be invoked from JavaScript with this name. For example, if a method is defined via:

<view id="obj">
  <method name="f" args="a, b">
    return a+b;
  </method>
</view>

then script code can invoke obj.f(1, 2) to add two numbers.

Superclass Chain

method

Known Subclasses

Details

Initial Attributes (4)

Initial Attributes are given as attributes in LZX but are not generally available as properties in JavaScript.

args
<attribute name="args" type="string" />
The parameter names of this method. The value of this attribute is a comma-separated list of JavaScript identifiers.
event
<attribute name="event" type="string" />
The name of the event that this method is invoked in response to.
name
<attribute name="name" type="token" />
The name of the method.
reference
<attribute name="reference" type="reference" value=""this"" />
If this attribute is present, it is a JavaScript expression that evaluates to an object. The code in this method executes when this object sends the event named by the @a{event} attribute. This attribute may be present only if the @a{event} attribute is present too.

LZX Synopsis

<class name="method">
</class>