Composite.common Class
Access point: ac.composite.* Provides methods for working with many Mojits.
Methods
done
-
opts
Automatically dispatches all the children of this mojit and collects their executed values into the view template, keyed by the child's name within the mojit's configuration. For example, given the mojit spec:
"specs": {
"parent": {
"type": "MyCompositeMojit",
"config": {
"children": {
"foo": {
"type": "FooMojit"
},
"bar": {
"type": "BarMojit"
}
}
}
}
}
And given the view template:
<div id="{{mojit_view_id}}">
<h1>{{title}}</h1>
<div class="fooslot">
{{{foo}}}
</div>
<div class="barslot">
{{{bar}}}
</div>
</div>
And the controller:
Y.mojito.controller = {
index: function(ac) {
ac.composite.done({
template: { title: 'Hello there' } // for the view only
});
}
};
This will execute the child intances of the "FooMojit" and "BarMojit", returning their rendered values into the parent's view template, thus rendering the full parent view including the children. All the parent parameters are passed along to children.
Parameters:
-
optsObjectThe configuration object to be used. template can be used to provide additional view template values.
execute
-
cfg -
cb
This method requires an explicit config object and returns a RMP compliant object via a callback.
cfg = {
children: {
slot-1: {
type: "default",
action: "index"
},
slot-2: {
type: "default",
action: "index",
params: {
route: {},
url: {},
body: {},
file: {}
}
}
},
assets: {}
}
The "callback" is an object containg the child slots with its rendered data.
callback({
slot-1: ,
slot-2:
},
{
http: {}
assets: {}
})
Parameters:
-
cfgObjectThe configuration object to be used.
-
cbFunctionThe callback that will be called.
