Any reason why binding to a list internally would be a bad idea?
var Person = can.Map.extend({
define: {
items: {
set: function(val) {
val.bind('change', console.log);
return val;
}
}
}
});
I believe we clean up those bindings when a new “items” list is set and when the instance of person is destroyed, but can’t recall offhand #lazyweb
also, should the can.List change event be adding nested properties to the index argument?
var list = new can.List();
list.bind(‘change’, function(ev, index) {});
var foo = new can.Map({ name: ‘foo’ });
list.push(foo); //index is 0, expected
foo.attr(‘name’, ‘bar’); //index is 0.name, I would expect 0
What’s everyone’s approach to abstracting out arbitrary data from a model?
For instance, suppose a user model:
{ id: 0, name: ‘Alexis’ }
However, in the template we would also want:
{ isEditing: false }
You wouldn’t want to add that attribute directly to the model as it has no benefit being sent back to the server(just view noise).
The elegant answer is inheritable defines(I think), but I’m curious what everyone’s approach has been thus far.