I have the following view to display a checked mark whenever the active
property is set:
App.ActiveEntryView = Ember.View.extend({
render: function(buffer) {
var active = this.get('active'), icon;
if (active) {
icon = 'fa fa-check';
} else {
icon = '';
}
return buffer.push(icon);
}
});
But this is not re-rendering if I the active
property changes. This is bound in my template like this:
{{#each model}}
<tr class="odd-even">
....
<td>{{view App.ActiveEntryView activeBinding="parked"}}</td>
....
</tr>
{{/each}}
Where parked
is the property of the model that I want to evaluate. But whenever that property changes in the model, the view is not re-rendered. I have tried adding an observer:
App.ActiveEntryView = Ember.View.extend({
render: function(buffer) {
var active = this.get('active'), icon;
if (active) {
icon = 'fa fa-check';
} else {
icon = '';
}
return buffer.push(icon);
}.observes('active')
});
But then I get an error:
Uncaught TypeError: undefined is not a function
Referring to the line:
return buffer.push(icon);
I guess that the observer triggers the render function passing a different parameter than buffer
.
How can I re-render the view then?