How can an observer find out the before and after values of the observed property in Ember.js?

后端 未结 4 710
梦谈多话
梦谈多话 2020-12-03 10:32

Please see the solution to another question provided by ud3323: http://jsfiddle.net/ud3323/ykL69/. This solution highlights the changed value using the red color. I have an

4条回答
  •  醉话见心
    2020-12-03 10:42

    I used a computed property to route to a model's property and store the last value upon its set.

    registrationGroup: Em.computed('regionModel.registrationGroup', 
    get:->
      @.get('regionModel.registrationGroup')
    set:(key, value, oldValue)->
      @.set('lastRegistrationGroup', oldValue)
      @.set('regionModel.registrationGroup', value)
    )
    

提交回复
热议问题