Skip to content

Commit

Permalink
Added section on 'Bindings and Chained Property Paths' to Core Concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Feb 2, 2011
1 parent b6906cc commit 9e5093e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions source/core_concepts.textile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -401,6 +401,29 @@ instead. In this case the local property (where the binding is defined) will
be updated when the remote property changes, but changes to the local be updated when the remote property changes, but changes to the local
property will not propagate to the remote property. property will not propagate to the remote property.


h4. Bindings and Chained Property Paths

Since bindings make use of observers behind the scenes, the same principles
of chained observers applies. This means that if you want to observe a
chained property, you will want to use asterisks in your path as appropriate.

<javascript>
MyApp.usersController = SC.ArrayController.create({
mainUser: SC.Object.create({
name: 'Joe'
})
});

MyApp.userNameView = SC.LabelView.create({
valueBinding: 'MyApp.usersController*mainUser.name'
});
</javascript>

Since we used an asterisk in the +valueBinding+ property path, the binding
will be updated if either +mainUser+ or +mainUser.name+ changes.

h4. Bindings Shorthand

Since bindings are used so often, there's also a shortcut to creating Since bindings are used so often, there's also a shortcut to creating
bindings. All you need to do is append +Binding+ to the property name. bindings. All you need to do is append +Binding+ to the property name.
In the above example, you could instead do: In the above example, you could instead do:
Expand Down Expand Up @@ -451,3 +474,5 @@ h3. Changelog
* January 12, 2011: initial partial version by "Peter Wagenet":credits.html#pwagenet * January 12, 2011: initial partial version by "Peter Wagenet":credits.html#pwagenet
* January 19, 2011: further updates by "Peter Wagenet":credits.html#pwagenet * January 19, 2011: further updates by "Peter Wagenet":credits.html#pwagenet
* January 20, 2011: corrections to "The +init+ Method" and "The Run Loop" by "Peter Wagenet":credits.html#pwagenet * January 20, 2011: corrections to "The +init+ Method" and "The Run Loop" by "Peter Wagenet":credits.html#pwagenet
* January 24, 2011: added section on "Bindings and Chained Property Paths" by "Peter Wagenet":credits.html#pwagenet

0 comments on commit 9e5093e

Please sign in to comment.