($click)=“attr('foo', *bar)”
assuming *bar
is in the ref scope
*foo
though
*
be an empty map
scope.attr()
works in the method but for some reason I couldn't get it to work in the expression
I have another performance question. I have a large stache template that creates one row of a div table. There are 156 rows to the entire table. The entire table is loaded and then reloaded as the page is loaded. The load takes about 4 seconds which isn’t great, but I can live with. The reload varies as shown below.
this.attr('player', player);
reloads in 1.5 seconds
if (this.attr('player')) {
this.attr('player').attr(player);
} else {
this.attr('player', player);
}
reloads in 4 seconds. Yet I was told the this was the better way to go.
get
function, can I set it up in a way that it builds a new object the first time its accessed and subsequent times it only modifies the existing object, rather than creating a brand new object? I have a template that uses this object and i'd like it to not have to re-render the entire template each time the object's dependents change.
this.attr('fields').forEach(function(fieldname){
newObj[fieldname] = {
alias: self.formatField(fieldname),
value: self.attr('formObject' + '.' + fieldname),
//other field properties
};
});
get
function
if (!this.objectBuilt) { build; this.objectBuilt = true;}
get: function(lastValue){
if(lastValue){
//modify and return lastValue
} else { /* build new value */}
this.attr(‘this field name’, object);
this.attr('fieldName', newValue);
instead of returning the object?
return this.attr('thisFieldName')
after setting the value
$el.viewModel()
$el.viewModel().someMethod()
$el.viewModel().xxx
can.grep()
Why is it that I cannot find any documentation on this function?