From 71af5f955db4dc66481d5c11849ad120babd5f4b Mon Sep 17 00:00:00 2001 From: atanasovg Date: Thu, 5 Jun 2014 14:16:35 +0300 Subject: [PATCH] Fixed improper unbind implementation --- ui/core/bindable.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/core/bindable.ts b/ui/core/bindable.ts index b26dc39bf..3928ffd32 100644 --- a/ui/core/bindable.ts +++ b/ui/core/bindable.ts @@ -51,6 +51,7 @@ class Binding { updating = false; source: observable.Observable; target: Bindable; + callback: (data: observable.PropertyChangeData) => void; constructor(target: Bindable, options: BindingOptions) { this.target = target; @@ -62,11 +63,11 @@ class Binding { this.updateTarget(this.source.getProperty(this.options.sourceProperty)); var that = this; - var callback = function (data: observable.PropertyChangeData) { + this.callback = function (data: observable.PropertyChangeData) { that.onSourcePropertyChanged(data); } - this.source.addObserver(observable.Observable.propertyChangeEvent, callback); + this.source.addObserver(observable.Observable.propertyChangeEvent, this.callback); } public unbind() { @@ -74,7 +75,7 @@ class Binding { return; } - this.source.removeObserver(observable.Observable.propertyChangeEvent, this.onSourcePropertyChanged); + this.source.removeObserver(observable.Observable.propertyChangeEvent, this.callback); this.source = undefined; this.target = undefined; }