Skip to content

Instantly share code, notes, and snippets.

@ColinCampbell
Created August 13, 2010 13:54
Show Gist options
  • Select an option

  • Save ColinCampbell/522923 to your computer and use it in GitHub Desktop.

Select an option

Save ColinCampbell/522923 to your computer and use it in GitHub Desktop.
// in apps/your_app/core.js, add: require('ext/binding');
// place this in apps/your_app/ext/binding.js:
SC.mixin(SC.Binding, {
firstObject: function() {
return this.transform(function(value, isForward) {
if (value && value.isEnumerable) {
value = value.firstObject();
}
return value;
});
}
});
// Usage:
MyApp.objController = SC.ObjectController.create(
/** @scope MyApp.objController.prototype */ {
contentBinding: 'Admin.arrController.selection',
contentBindingDefault: SC.Binding.firstObject()
}) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment