I want to change the value of two properties of an Ember Component inside a Mixin it extends.
MyMixin = Ember.Mixin.create
init: ->
@set 'threshold', undefined
@set 'oldItems', undefined
@_super(arguments...)
itemsLengthObserver: Ember.observer('items.content.length', ->
actualItems = @get('items.content.length') or 0
threshold = @get('threshold')
oldItems = @get('oldItems')
if actualItems > 0 and not threshold
@set 'oldItems', actualItems
@set 'threshold', true
else
....
If I breakpoint after the @set threshold line and check the values for oldItems and threshold I can see the values were properly changed, however next time the items.content.length changes, values appear to be reset to default (both undefined)
Aucun commentaire:
Enregistrer un commentaire