I have the following 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')
The problem is after I call push object, the length is still
0. I really cannot see what I am doing wrong.
Can anyone see what I am doing wrong? The only thing I can think of is that the Content is set to an empty array via
I have no idea what else it could be.
preguntado el 09 de marzo de 12 a las 15:03
I'm not quite sure where your problem is since I a) don't really know or use CoffeeScript and b) there's no jsFiddle or working example. But if I'm reading this correctly your trying to do the following: Ver este jsFiddle which works as expected. Hope that points you in the right direction.
Se trata de un Guión de café error de sintaxis.
There are two solutions (depending on what you want to implement).
The second example will use the same array for every instance of the controller.
Also, I'd recommend calling
@_super() when overriding the init method, otherwise you might get some unexpected results with certain classes.
Ember.ArrayController.extend init: -> @_super() @set 'content', Ember.A() # content Ember.ArrayController.extend content: Ember.A() init: -> @_super() # content