Skip to content

Instantly share code, notes, and snippets.

@ialexi
Created October 7, 2011 05:19
Show Gist options
  • Save ialexi/1269521 to your computer and use it in GitHub Desktop.
Save ialexi/1269521 to your computer and use it in GitHub Desktop.
// I just found out that .bind automatically sets up chained bindings in SproutCore. When did that get added?
var data = SC.Object.create({ insideObject: SC.Object.create({ property: "Value" }) });
var view = SC.Object.create();
view.bind('prop', data, 'insideObject.property');
// expected:
SC.RunLoop.end();
console.log(view.get('prop')); // -> "Value"
// also expected:
data.setPath('insideObject.property', "Hi");
SC.RunLoop.end();
console.log(view.get('prop')); // -> "Hi"
// not expected:
data.set('insideObject', SC.Object.create({ property: "Hiyo!" }));
SC.RunLoop.end();
console.log(view.get('prop')); // "Hiyo!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment