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.
Applies additional styles (prefixed with '.' in the TSS file). Overwrites the element style but not the id style.
|Enables the autostyle feature for dynamic styling when adding or removing classes. See Dynamic Styles: Autostyle for more details.|
|Use a custom query to apply additional styles to the element. See Conditional Codecode and Alloy Styles and Themes: Custom Query Styles for more details.|
|Requires in a CommonJS module. Note that the XML element must be named after a |
Overrides the default
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 Codecode and Namespace for more details.
The following table lists the special XML elements besides the Titanium UI components:
Root element for all view XML files. Required in all views.
|Creates a singleton or instance of the specified collection. See the Collection Elementelement for more details.|
|Creates a singleton or instance of the specified model. See the Model Elementelement for more details.|
|Imports a module view inside this view. See the Module Elementelement for more details.|
index.xml is a special case that only accepts the following view components as direct children of the Alloy tag:
Within a view in the regular Alloy project space (
app/views), use the
<Widget> tag to import the widget into the application. A
<Widget/> element is equivalent to a
<Require/> element whose
type attribute is set to "widget".
var title = $.args.customTitle || 'Foobar'; var image = $.args.customImage || 'default.png';
See Alloy Controllers: Passing Arguments for more details.
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:
You can also create subfolders, named as the platform, in the
views directory as another way to create platform-specific views. Refer to to Alloy Concepts: Platform-Specific Resources.
Each Titanium UI object property is defined as an attribute in the XML markup and TSS file if it accepts a string, boolean, number or Titanium SDK constant, such as
Ti.UI.TEXT_ALIGNMENT_CENTER. Setting properties in the XML markup overrides the settings in the TSS file. Node text can also be used to define the Label text and Button title properties.