Top-level module for Alloy functions.
Alloy is an application framework built on top of the Titanium SDK designed to help rapidly develop high quality applications and reduce maintenance.
Alloy uses the model-view-controller architecture to separate the application into three components:
Models provide the data of the application. Alloy utilizes Backbone Model and Collection objects for this functionality.
Views provide the UI components to interact with the application, written using XML markup and Titanium Stylesheets (TSS), which abstracts the UI components of the Titanium API.
Controllers provide the glue layer between the Model and View components as well as additional application logic using the Alloy API and Titanium API.
The API documentation provided here is used with Alloy Controllers and Widget Controllers to interact with the View and Model components of the application or widget.
For guides on using Alloy, see Alloy Framework.
An object that stores Alloy configuration values as defined in your app's app/config.json file. Here's what a typical config.json file might look like in an Alloy app.
{
"global": { "key": "defaultValue", "anotherKey": 12345 },
"env:development": {},
"env:test": {},
"env:production": {},
"os:ios": { "key": "iosValue" },
"os:android": { "key": "androidValue" },
"dependencies": {}
}
If this app was compiled for iOS, the Alloy.CFG would look like this:
Alloy.CFG = {
"key": "iosValue",
"anotherKey": 12345
}
Alloy.CFG is accessible in any controller in your app, and can be accessed in other non-controller Javascript files like this:
var theKey = require('alloy').CFG.key;
An object for storing globally accessible Alloy collections. Singleton collections created via markup will be stored on this object.
<Collection src="myModel"/>
The above markup would effectively generate the following code:
Alloy.Collections.myModel = Alloy.createCollection('MyModel');
Alloy.Collections.myModel would then be accessible in any controller in your app.
An object for storing globally accessible variables and functions. Alloy.Globals is accessible in any controller in your app:
Alloy.Globals.someGlobalObject = { key: 'value' };
Alloy.Globals.someGlobalFunction = function(){};
Alloy.Globals can be accessed in other non-controller Javascript files like this:
var theObject = require('alloy').Globals.someGlobalObject;
An object for storing globally accessible Alloy models. Singleton models created via markup will be stored on this object.
<Model src="myModel"/>
The above markup would effectively generate the following code:
Alloy.Models.myModel = Alloy.createModel('MyModel');
Alloy.Models.myModel would then be accessible in any controller in your app.
true
if the current device is a handheld device (not a tablet).
true
if the current device is a handheld device (not a tablet).
Factory method for instantiating a Backbone collection of model objects. Creates and returns a collection for holding the named type of model objects.
See Backbone.Collection in the Backbone.js documentation for information on the methods and properties provided by the Collection object.
Name of model to hold in this collection.
Arguments to pass to the collection.
Backbone collection object.
Factory method for instantiating a controller. Creates and returns an instance of the named controller.
Name of controller to instantiate.
Arguments to pass to the controller.
Alloy controller object.
Factory method for instantiating a Backbone Model object. Creates and returns an instance of the named model.
See Backbone.Model in the Backbone.js documentation for information on the methods and properties provided by the Model object.
Name of model to instantiate.
Arguments to pass to the model.
Backbone model object.
Factory method for instantiating a widget controller. Creates and returns an instance of the named widget.
Id of widget to instantiate.
Name of the view within the widget to instantiate ('widget' by default)
Default: "widget"Arguments to pass to the widget.
Alloy widget controller object.