<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)
它仅在我刷新或从其他视图转到时才有效。
答案 0 :(得分:4)
绑定帮助程序实际上需要一个附加选项,这是附加的依赖键。对于数组,您需要将@each
指定为依赖项。在我的头顶,这看起来像:
Ember.Handlebars.registerBoundHelper 'kudosReceivedNum', ((kudos, options) ->
kudosTotal = 0
if kudos
kudos.forEach (item) ->
kudosTotal += item.get 'value'
kudosTotal), '@each'