Skip to content

Commit

Permalink
Fixed issue with updating nested properties via binding.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nedyalko Nikolov authored and ErjanGavalji committed Jun 10, 2015
1 parent 0dc6156 commit ffc1fcb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions apps/tests/ui/bindable-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,36 @@ export function test_BindingToDictionaryAtAppLevel() {
}

helper.buildUIAndRunTest(createLabel(), testFunc);
}

export function test_UpdatingNestedPropertyViaBinding() {
var expectedValue1 = "Alabala";
var expectedValue2 = "Tralala";
var viewModel = new observable.Observable();
var parentViewModel = new observable.Observable();
viewModel.set("parentView", parentViewModel);
parentViewModel.set("name", expectedValue1);

var testElement: bindable.Bindable = new bindable.Bindable();

testElement.bind({
sourceProperty: "parentView.name",
targetProperty: "targetName",
twoWay: true
}, viewModel);

var testElement2: bindable.Bindable = new bindable.Bindable();

testElement2.bind({
sourceProperty: "parentView.name",
targetProperty: "targetProperty",
twoWay: true
}, viewModel);

TKUnit.assertEqual(testElement.get("targetName"), expectedValue1);

testElement.set("targetName", expectedValue2);

TKUnit.assertEqual(parentViewModel.get("name"), expectedValue2);
TKUnit.assertEqual(testElement2.get("targetProperty"), expectedValue2);
}
2 changes: 1 addition & 1 deletion ui/core/bindable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class Binding {
else {
this.updateTarget(expressionValue);
}
} else if (data.propertyName === this.options.sourceProperty) {
} else if (data.propertyName === this.sourceOptions.property) {
this.updateTarget(data.value);
}
}
Expand Down

0 comments on commit ffc1fcb

Please sign in to comment.