view.Core Class
Base class for components and views in ludoJS. This class extends Mootools Events class.
Item Index
Properties
Attributes
Methods
addControllerEvents
()
Add events to controller
Returns:
Example:
this.controller.addEvent('eventname', this.methodName.bind(this));
getId
()
Return id of component
Returns:
getName
()
Get name of component and form element
Returns:
getNamespace
()
String
Returns component type minus class name, example: type: calendar.View will return "calendar"
Returns:
saveState
()
Save state for stateful components and views. States are stored in localStorage which is supported by all major browsers(IE from version 8).
Returns:
Example:
myComponent.saveState();
OR
this.fireEvent('state');
which does the same.
Properties
statefulProperties
Array
Array of stateful properties. These properties will be saved to local storage when "change" event is fired by the component
Default: undefined
Attributes
addOns
Array
Array of add-ons config objects Add-ons are special components which operates on a view. "parentComponent" is sent to the constructor of all add-ons and can be saved for later reference.
Example:
new ludo.View({
plugins : [ { type : 'plugins.Sound' }]
});
Add event
this.getParent().addEvent('someEvent', this.playSound.bind(this)); Which will cause the plugin to play a sound when "someEvent" is fired by parent component.
controller
Object
Reference to a specific controller for the component. The default way is to set useController to true and create a controller in the same namespace as your component. Then that controller will be registered as controller for the component. The 'controller' property can be used to override this and assign a specific controller
If you create your own controller by extending ludo.controller.Controller, you can control several views by adding events in the addView(component) method.
Fires event controllerChange
Fires when the value for the configuration attribute controller
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
Example:
controller : 'idOfController'
controller : { type : 'controller.MyController' }
A Controller can also be a singleton.
name
string
When creating children dynamically using config objects(see children) below, you can access a child
by component.childname if a name is passed in the config object.
NB. The config properties listed below are sent to the constructor when creating the component
Fires event nameChange
Fires when the value for the configuration attribute name
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
stateful
Boolean
Save states from session to session. This can be set to true for components and views where statefulProperties is defined. The component also needs an "id".
Default: false
Fires event statefulChange
Fires when the value for the configuration attribute stateful
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
userController
Boolean
Find controller and register this component to controller
Default: false
Fires event userControllerChange
Fires when the value for the configuration attribute userController
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added: