API Docs for: 0.0.2
Show:

view.Core Class

Defined in: api/src/core.js:1
Module: language

Base class for components and views in ludoJS. This class extends Mootools Events class.

Methods

addControllerEvents

()

Defined in api/src/core.js:243

Add events to controller

Returns:

void

Example:

this.controller.addEvent('eventname', this.methodName.bind(this));

getId

()

Defined in api/src/core.js:162

Return id of component

Returns:

String id

getName

()

Defined in api/src/core.js:170

Get name of component and form element

Returns:

String name

getNamespace

() String

Defined in api/src/core.js:211

Returns component type minus class name, example: type: calendar.View will return "calendar"

Returns:

String: namespace

getUrl

() String | Undefined

Defined in api/src/core.js:180

Get url for component

Returns:

String | Undefined: url

saveState

()

Defined in api/src/core.js:265

Save state for stateful components and views. States are stored in localStorage which is supported by all major browsers(IE from version 8).

Returns:

void

Example:

myComponent.saveState();

OR

this.fireEvent('state');

which does the same.

Properties

dependency

Object private

Defined in api\src\core.js:66

Storage of ludoJS classes this object is depending on

statefulProperties

Array

Defined in api\src\core.js:57

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

Defined in api\src\core.js:73

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

Defined in api\src\core.js:20

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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.

Defined in api\src\core.js:9

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

stateful

Boolean

Defined in api\src\core.js:47

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

userController

Boolean

Defined in api\src\core.js:40

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.