MODULES Uize.Class.mModels
1. Introduction
The Uize.Class.mModels mixin implements features to provide a declarative approach to adding and binding models to a Uize.Class subclass.
DEVELOPERS: Ben Ilegbodu, original code contributed by Zazzle Inc.
1.1. Use Cases
The cases in which you would want to use the Uize.Class.mModels minin are...
1.1.1. A class model with sub-models
.
NOTES
| Creating sub-models from state | |
| Binding state of parent to state of sub-models | |
| Wiring sub-model events |
1.1.2. A class that takes a model as state
.
NOTES
| Parent will need to be able to pass model to class | |
| Class will bind state of itself to state of passed model | |
| Class will wire events on passed model |
1.1.3. A class that takes a model as state, but will create one if not passed
.
NOTES
| Parent will need to be able to pass model to class | |
| Class will also create model, but only if model was not passed at time of construction | |
| Class will bind state of itself to state of passed model | |
| Class will wire events on passed model |
1.2. Examples
There are no dedicated showcase example pages for the Uize.Class.mModels module.
SEARCH FOR EXAMPLES
Use the link below to search for example pages on the UIZE Web site that reference the Uize.Class.mModels module...
SEARCH
1.3. Implementation Info
The Uize.Class.mModels module defines the Uize.Class.mModels object under the Uize.Class namespace.
1.3.1. Features Introduced in This Module
The features listed in this section have been introduced in this module.
STATIC PROPERTIES
Uize.Class.mModels.moduleName | Uize.Class.mModels.pathToResources
1.3.2. Features Overridden in This Module
No features have been overridden in this module.
1.3.3. Features Inherited From Other Modules
This module has no inherited features.
1.3.4. Modules Directly Under This Namespace
There are no modules directly under this namespace.
1.3.5. Unit Tests
The Uize.Class.mModels module is unit tested by the Uize.Test.Uize.Class.mModels test module.
2. State Properties
2.1. models
A special state property that provides a way to distribute model properties to any or all of the class instance's models, or even models of the class instance's models - all the way down to the deepest models in the class instance's model tree.
NOTES
| see also the companion model instance property |
3. Instance Properties
3.1. addedModels
A Uize.Class instance whose state properties reflect whether or not models by the same name has been added.
You can use the condition system methods like isMet, once, and whenver on addedModels to determine if and when a model has been added to the class instance.
NOTES
the addedModels object is read-only - its state should not be directly modified |
|
see also the related models instance property |
3.2. models
An object, each of whose properties is a reference to one of a class instance's models.
For example, an instance of the Uize.Widget.SlideShow class assigned to the variable mySlideShow may have models that can be referenced as follows...
mySlideShow.models.images
3.2.1. Don't Directly Modify the models Object
The contents of the models object is managed by the various instance methods of the Uize.Class.mModels class mix-in, such as the addModel and removeModel methods.
One should not directly modify the contents of the model object, but should only do this through the model management methods.
3.2.2. The Special model state Property
The model instance property has a companion state property of the same name, but which has a special behavior.
The model state property provides a convenient way to distribute model properties to any or all of a class instance's models.
NOTES
the model object is read-only - its contents should not be directly modified |
|
| see also the special model state property |
4. Instance Methods
4.1. addModel
The addModel method lets you add a Uize.Class model object to an existing Uize.Class subclass.
SYNTAX
modelOBJ = myClass.addModel (modelNameSTR, modelClassOBJ, modelPropertiesOBJ);
VARIATION
modelOBJ = myClass.addModel (modelNameSTR, modelClassOBJ);
The modelPropertiesOBJ parameter is optional and can be omitted when the default property values for a model class are sufficient, or when the properties will be set to the desired values at a later stage.
NOTES
| returns a reference to the model instance that was added | |
a state property matching the child widget name is marked as met in the addedModels instance property |
|
the value of the modelNameSTR can be null, undefined or '' if a value is specified for the name property in the modelPropertiesOBJ parameter |
|
see also the removeModel instance method, and the model instance property
|
4.2. removeChild
The removeChild instance method lets you remove a child widget from a widget.
SYNTAX
myWidget.removeChild (childWidgetSTRorOBJ);
When using this method, the child widget to remove can be specified by its name, or by an object reference to it.
NOTES
a state property matching the model name is marked as unmet in the addedModels instance property |
|
see also the addModel instance method, and the models instance property |