javascript - Ember, observers trigger in a strange order -
here's controller eventtimezonecontroller
. content
property set event
model.
app.challengetimezonecontroller = ember.objectcontroller.extend timezones: [{value: "", label: ""}, {...}] timezonedidchange: (-> console.log "in controller", @get("timezone") ).observes("timezone") # tried "content.timezone"
and event
model:
app.event = app.challenge = ds.model.extend(ember.validations, timezone: ds.attr('string') timezonedidchange: (-> console.log "in model", @get("timezone") ).observes("timezone") )
and then, have timezoneselect
view
app.timezoneselect = ember.select.extend valuebinding: "controller.timezone" contentbinding: "controller.timezones" optionvaluepath: "content.value", optionlabelpath: "content.label"
now here's problem: when select new value in select dropdown, log shows:
> in controller american samoa > in model american samoa
why method timezonedidchange
controller called before 1 in model, since understand, it's observing property of model?
in ember.js
, controllers meant proxy model, makes sense call computed properties function on controller first. reference can check out informative talk luke melia @ ember.js nyc at min 31:30 slide shown concept.
hope helps
Comments
Post a Comment