nullnullnull
nullnullnull

Reputation: 8189

Updating computed properties in ember.js

Are computed properties suppose to live update? I have this computed property:

fullName: (->
  firstName + " " + lastName
).property('firstName lastName')

When typing into the firstName or lastName fields, the computed property doesn't update until I rerender the page. Is this intended behavior? If so, how can I trigger an update? I've attempted to use an observer, but it doesn't even trigger:

nameChanged: (->
  alert "Triggered!"
).observes('firstName lastName')

The only time it goes off is when I rerender the page.

Upvotes: 0

Views: 66

Answers (1)

mavilein
mavilein

Reputation: 11668

You have to specify the properties as comma separated list:

fullName: (->
  firstName + " " + lastName
).property('firstName', 'lastName')

The same is true for observers:

nameChanged: (->
  alert "Triggered!"
).observes('firstName', 'lastName')

I did the same mistake some months ago :-)

Upvotes: 2

Related Questions