The <attribute>
tag has two uses:
In a class definiiton, the <attribute>
tag defines an
attribute that can be set in instances of the class.
<canvas
height
="30
"> <class
name
="mybutton
" extends
="button
"> <attribute
name
="myattr
" type
="string
" value
="after
"/> </class
>
<mybutton
text
="before
" myattr
="after
" onclick
="setAttribute('text', this.myattr)
"/>
</canvas
>
In an instance, the <attribute>
tag attaches an
attribute to the instance. The attribute can be accessed from script.
<canvas
height
="30
"> <class
name
="mybutton
" extends
="button
"> <attribute
name
="myattr
" type
="string
" value
="after
"/> </class
> <mybutton
text
="before
" onclick
="setAttribute('text', this.myattr)
">
<attribute
name
="myattr
" value
="perhaps later
"/> </mybutton
> </canvas
>
See the Developer's Guide for a complete discussion.
Also see the documentation for <class>
. The Classes tutorial describes how
to use attributes to define a class.
Name (CSS property) | Type (tag) | Type (js) | Default | Category |
---|---|---|---|---|
allocation
|
"instance" | "class" | String | "instance" | initialize-only |
One of:
You can set <attribute name="allowed" value="false" type="boolean" allocation="class" /> |
||||
name
|
String | initialize-only | ||
The name of the attribute. | ||||
required
|
Boolean | "false" | initialize-only | |
True if this is a required attribute. | ||||
style
|
String | initialize-only | ||
The CSS property name that can be used to set the value of this
attribute under the control of a
<stylesheet> (See Chapter 19. Cascading Style Sheets
). style can be any valid CSS property name, and
need not be the same as the attribute name; for example you could
use the standard CSS property name
background-color as the style of the
bgcolor attribute. When an attribute has a
style property, the value
property acts as the default value for the attribute: in the absence
of any applicable CSS rule specifying the corresponding property,
the attribute will be given the default value. In the case of
dynamic CSS, the attribute will revert to the default value if CSS
was applied and is removed. (See Dynamic CSS .)
|
||||
type
|
"boolean" | "color" | "expression" | "number" | "size" | "string" | "text" | "html" | String | "expression" | initialize-only |
The type of the attribute. This determines how the value is parsed. Attributes of type string are automatically quoted if when="immediate", for any other value of when, a literal string would have to be quoted to be used as a value. | ||||
value
|
Object | read/write | ||
The initial value of the attribute. The type of this value is specified by the value of the type attribute; if that attribute is not present, it's the type of this attribute in this element's tag. The attribute is given this value when the element is created. |
Copyright © 2002-2010 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.