Reputation: 1765
<span class="badge badge-inverse">{{kudosReceivedNum user.kudoReceiveds}}</span>
Ember.Handlebars.registerBoundHelper 'kudosReceivedNum', (kudos, options) ->
kudosTotal = 0
if kudos
kudos.forEach (item) ->
kudosTotal += item.get 'value'
kudosTotal
ApplicationRoute:
newKudo = Sks.KudoReceived.createRecord value: kudoNum, comment: kudoComment
user.get('kudoReceiveds').pushObject(newKudo)
It only works when I do a refresh or go from another view.
Upvotes: 2
Views: 134
Reputation: 7937
Bound helpers actually take an additional option which are additional dependent keys. For arrays you need to specify @each
as a dependency. Off the top of my head this would look like:
Ember.Handlebars.registerBoundHelper 'kudosReceivedNum', ((kudos, options) ->
kudosTotal = 0
if kudos
kudos.forEach (item) ->
kudosTotal += item.get 'value'
kudosTotal), '@each'
Upvotes: 4