Class MBX.JsController
Defined in: js_controller.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Create and extend controllers
|
| Field Attributes | Field Name and Description |
|---|---|
| <static> |
MBX.JsController.Event
This is mostly used internally and is fired on MBX everytime a controller is created
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
MBX.JsController.create(name, opts)
Controllers allow some decently powerful hooks.
|
| <static> |
MBX.JsController.destroyController(name)
Destroy a controller and unsubscribe its event listeners
|
| <static> |
MBX.JsController.extend(methsAndAttrs)
call extend() to add methods and/or attributes to ALL controllers
|
Field Detail
<static>
MBX.JsController.Event
This is mostly used internally and is fired on MBX everytime a controller is created
Method Detail
<static>
MBX.JsController.create(name, opts)
Controllers allow some decently powerful hooks. You can specify a model, and an
onInstanceChange, onInstanceDestroy, onInstanceCreate.
If your controller listens to a model, but you are not dependent on real-time updates,
you can add the option "looselyCoupled: true" and all updates will be done with
setTimeout, which will be a performance enhancement.
MBX.DesktopUploadController = MBX.JsController.create("DesktopUpload", {
looselyCoupled: false, // false is the default
ANewMethod: function (something) {
return something;
}
})
MBX.DesktopUpload.ANewMethod("boo") == "boo";
MBX.DesktopUploadController = MBX.JsController.create("DesktopUpload", {
model: MBX.DesktopUpload,
onInstanceCreate: function (instance) {
alert(instance.get('greeting'));
}
});
MBX.DesktopUpload.create({ greeting: 'hi' }); // will alert('hi');
MBX.DesktopUploadController = MBX.JsController.create("DesktopUpload", {
model: MBX.DesktopUpload,
onInstanceChange: function (instance) {
alert(instance.get('greeting'));
}
});
var instance = MBX.DesktopUpload.create();
instance.set('greeting', 'hi'); // will alert('hi')
- Parameters:
- {String} name
- the name of the controller
- {Object} opts
- used to extend the controller methods at instantiation
- See:
- JsController
<static>
MBX.JsController.destroyController(name)
Destroy a controller and unsubscribe its event listeners
- Parameters:
- {String} name
- the name of the controller
<static>
MBX.JsController.extend(methsAndAttrs)
call extend() to add methods and/or attributes to ALL controllers
- Parameters:
- {Object} methsAndAttrs