Ilayaperumal Gopinathan
unread,Jan 23, 2013, 12:37:35 PM1/23/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I am trying to understand some of the cola concepts and would need some help to get it right.
Following is the step by step process I am trying to do to achieve model view binding:
1) Define cola 'Hub/Base' object: either Model or Collection
2) Bind this cola object to the view component and my bind facet has the following options:
to: (cola object created at step 1)
bindings: (some of the DOM handlers)
3) Bind the cola object(from step1) to the item data. Here I want to bind my model that is set from a REST API to this cola object.
Here are my questions:
Should I always have the cola adapters (from cola/adapter/) bind to the cola object that in turn connect to the actual model (from my Step3)?
For example, the cola ArrayAdapter uses a data array to create the ArrayAdapter object and we can make this bind to the cola 'Hub/Base' object.
In my wirespec, I am doing something like this:
colaCollection: {
create: { module: 'cola/Collection' }
}
view1: {
render: {...},
bind: {
to: {
$ref: 'colaCollection'
},
bindings: { some DOM Handlers here }
}
}
dataSourceArray: {
create: {
module: 'cola/adapter/Array',
args: [ { $ref: 'Controller.thatReturnsDataArray' } ]
},
bind: {
to: { $ref: 'colaCollection' }
}
}
dataSourceQuery: {
create: {
module: 'cola/adapter/Query',
args: [ { $ref: 'Controller.thatImplementsqueryfunction' } ]
},
bind: {
to: { $ref: 'colaCollection' }
}
}
Here, the controller's query function does the REST request to get the data.
The way I understand this from some of the demo apps: the cola adapters(cola/adapter/Array, Object, LocalStorage, Query etc.,) act as the data source and the DOM adapters (Node, NodeList) act as the destination.
A bit of explanation on the overview on how to define the cola binding to view and model would very much help!
Thanks in advance,
-- Ilaya