<behavior>
The <behavior>
element allows adding multiple behaviors to UI elements such as <view>
, <text>
, <image>
, etc.
<view style="Button">
<behavior trigger="press" href="/display" />
<behavior trigger="longPress" href="/edit" target="new" />
<text style="Button__Label">Item</text>
</view>
The example above shows a button with two behaviors:
- When the button is pressed, we request "/display" and push the content as a new screen.
- When the button is long-pressed, we request "/edit" and show the content as a modal.
<behavior>
elements can be mixed with behavior attributes on the parent element. The example below works the same as the one above.
<view style="Button" trigger="press" href="/display">
<behavior trigger="longPress" href="/edit" target="new" />
<text style="Button__Label">Item</text>
</view>
Structure
A <behavior>
element defines a behavior that applies to its direct parent element. The following elements can contain <behavior>
elements as a direct child:
Attributes
Behavior attributes
A <behavior>
element accepts the standard behavior attributes. The supported triggers depend on the parent element.