Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Attribute

Description

id

Identifies UI elements in the controller (prefixed with $.) and style sheet (prefixed with #). IDs should be unique per view but are not global, so multiple views can have components with the same ID.

class

Applies additional styles (prefixed with . in the TSS file). Overwrites the element style but not the id style.

autoStyleEnables the autostyle feature for dynamic styling when adding or removing classes. See Dynamic Styles: Autostyle for more details.

formFactor

Acts as a compiler directive for size-specific view components. Value can either be handheld or tablet. See Conditional code for more details.

ifUse a custom query to apply additional styles to the element. See Conditional code and Alloy Styles and Themes: Custom Query Styles for more details.
moduleRequires in a CommonJS module. Note that the XML element must be named after a create<XMLElement> method in the module. See Module Attribute for more details.

ns

Overrides the default Titanium.UI namespace. See Namespace for more details.

platform

Switches the namespace based on the platform and acts as a compiler directive for platform-specific view components. Values can be any combination of platforms. See Conditional code and Namespace for more details.

<properties>

Assigns values to UI object properties. See Property mapping for more details.

<events>

Assigns callbacks to UI object events. See Event handling for more details.

The following table lists the special XML elements besides the Titanium UI components:

Element

Description

Alloy

Root element for all view XML files. Required in all views.

CollectionCreates a singleton or instance of the specified collection. See the Collection element for more details.
ModelCreates a singleton or instance of the specified model. See the Model element for more details.
ModuleImports a module view inside this view. See the Module element for more details.

Require

Imports a widget or includes another view inside this view. See the Require element for more details.

Widget

Imports a widget inside this view. Same as the Require element with the type specified to 'widget'. See Importing widgets for more details.

index.xml is a special case that only accepts the following view components as direct children of the Alloy tag:

...

To bind a callback to an event in a required view using the on attribute as detailed in Event Handling below, add an event listener for the UI component to trigger the event. For example, suppose you want to require a view that only contains a button. In the parent view, you require the button view and assign a callback to the click event:

...