emberjs/ember.js — Issue #464: Views have a race condition that appears when CoffeeScript is used
Author: rspeer
Created: 2012-01-31 18:11:22+00:00
State: open

When I define ember.js views in CoffeeScript that's compiled on the fly, I notice that the views will sometimes fail to load, in what appears to be a race condition.

I can inspect their content and see that they have items in them, but an {{#each}} or {{#collection}} that iterates over them will appear empty, and will remain empty even when I add more items using the ArrayProxy.addObject method.

Here's a code example:

```coffee
this.Lui = Lui = Ember.Application.create()

Lui.CanonicalTopic = Ember.Object.extend {
name: 'default'
terms: ''
color: '#7f7f7f'
selected: (->
Lui.topicController.get('selected') == this.get('name')
).property()
}

Lui.topicController = Ember.ArrayProxy.create {
content: null
selected: 'example'

init: ->
this._super()
this.set('content', [])

addTopic: (props) ->
this.addObject(Lui.CanonicalTopic.create(props))
}

Lui.topicController.addTopic {
name: 'example'
color: '#0000ff'
}
```

And the view code:
```html

```

Pre-compiling the CoffeeScript into a .js file (the more standard way of running CoffeeScript) makes the problem disappear, so it could be a problem in CoffeeScript, but I think it's more likely revealing a race condition in Ember by doing more evaluation on page load than it expects.