cherifGsoul on upgrade-docs-html-canjs
cherifGsoul on master
Upgrade the site theme for new … (compare)
cherifGsoul on upgrade-docs-html-canjs
Upgrade the site theme for new … (compare)
searchTermChanged: function(el, ev){
var searchTerm = el.val();
this.scope.attr('searchTerm', searchTerm);
},
’el event’: ‘handler’
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.
they would be on a viewmodel, just not the component’s necessarily. imagine you have a user model and your component has a user.list. user.isSelected could be some property you want to set.
In your view, you’d probably have something like:
{{#each users}}
<input type=“checkbox” can-value=“{isSelected}”/>
{{/each}}
isSelected
would be convenient at some lower level than the component viewmodel itself, but not necessarily all the way down to the model.