Javascript 余烬,观察者以一种奇怪的顺序触发

Javascript 余烬,观察者以一种奇怪的顺序触发,javascript,select,binding,ember.js,Javascript,Select,Binding,Ember.js,这是我的控制器EventTimezoneController。其内容属性设置为事件模型 App.ChallengeTimezoneController = Ember.ObjectController.extend timezones: [{value: "", label: ""}, {...}] timezoneDidChange: (-> console.log "In controller", @get("timezone") ).obse

这是我的控制器
EventTimezoneController
。其
内容
属性设置为
事件
模型

App.ChallengeTimezoneController = Ember.ObjectController.extend
    timezones: [{value: "", label: ""}, {...}]

    timezoneDidChange: (->
        console.log "In controller", @get("timezone")
    ).observes("timezone") # I also tried "content.timezone"
现在是我的
事件
模型:

App.Event = App.Challenge = DS.Model.extend(Ember.Validations,
    timezone: DS.attr('string')

    timezoneDidChange: (->
        console.log "In model", @get("timezone")
    ).observes("timezone")
)
然后,我有一个
时区选择
视图

App.TimezoneSelect = Ember.Select.extend
  valueBinding: "controller.timezone"
  contentBinding: "controller.timezones"
  optionValuePath: "content.value",
  optionLabelPath: "content.label"

现在问题出在这里:当我在选择下拉列表中选择一个新值时,日志显示:

> In controller American Samoa
> In model American Samoa

为什么控制器中的方法
timezoneDidChange
在模型中的方法之前调用,因为据我所知,它正在观察模型的属性?

ember.js
中,控制器是用来代理模型的,所以首先调用控制器上的computed properties函数是有意义的。作为参考,您可以查看这篇内容丰富的文章,尤其是在幻灯片中显示了该概念的地方


希望对您有所帮助

这是一个输入错误,或者您是否错过了模型中
时区更改:
中的
->
?我明白您的意思。只是我从控制器触发了方法
timezoneDidChange
中的保存。发生的事情是,当时,时区值已更改,但模型状态管理器尚未注册它,这导致事务失败和其他问题。。。