Skip to content

Instantly share code, notes, and snippets.

@publickeating
Created March 6, 2013 02:48
Show Gist options
  • Save publickeating/5096315 to your computer and use it in GitHub Desktop.
Save publickeating/5096315 to your computer and use it in GitHub Desktop.
/**
* Imagine if you will that the content of this controller is set to a bunch of MyApp.Person records. For whatever reason
* we don't want to pass those records as is to the controller or view using peopleController objects.
*/
MyApp.peopleController = SC.ArrayController.create({
// Override to provide the proper object for our consumer of peopleController objects.
objectAt: function (idx) {
var content = this.get('content'),
person,
ret;
if (content) {
person = content.objectAt(idx);
ret = {
icon: person.get('role') === 'admin' ? sc_static('admin-icon.png') : sc_static('regular-icon.png'),
title: person.get('firstName') + ' ' + person.get('lastName')
};
}
return ret;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment