Javascript Functions

Javascript Functions

Appcelerator has several Javascript functions that you may find useful while developing applications with Appcelerator.

Message Publish and Subscribe Functions

Here’s an example of the $MQ function

$MQ("l:show.calendar",{"username":"foo"});

Here’s an example of the $MQL function

$MQL("l:show.calendar",function(type,msg)
   {
	// your code
   });

You callback function is passed the message type (type) and the message data payload (msg).

Compiler Functions

Cookie Functions

Date Functions

Validators and Decorators

You can also call validators and decorators via Javascript. Here’s a couple of examples:

	Appcelerator.Validator.required(value)

	Appcelerator.Decorator.required(element, valid, decId)

In the two examples above, we call the “required” decorator and validator. Each validator function requires the value of an element to be passed in. Each decorator function requires the element and whether the element is valid. You can also optional pass in the decorator ID for the decorator if applicable.