我有以下 ArrayController:
Lead.Controllers.Leads = Ember.ArrayController.extend
init: ->
content: Ember.A()
@view = Ember.View.create
controller: @
templateName: 'app/templates/leads/list'
@view.appendTo $('#leads')
addLead: (data) ->
lead = Lead.Lead.create()
lead.setProperties JSON.parse data
console.log lead.get 'company'
debugger
@pushObject lead
console.log @get('length')
问题是在我调用推送对象后,长度仍然是0
。我真的看不出我做错了什么。
谁能看出我做错了什么?我唯一能想到的是通过 Ember.A()
将 Content 设置为一个空数组。
我不知道它还能是什么。
最佳答案
我不太确定您的问题出在哪里,因为我 a) 并不真正了解或使用 CoffeeScript,并且 b) 没有 jsFiddle 或工作示例。但是,如果我没看错的话,你会尝试执行以下操作:See this jsFiddle按预期工作。希望这能为您指明正确的方向。
关于coffeescript - Ember.js PushObject 没有在 ArrayController 中插入对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9636788/