Created
March 6, 2013 02:48
-
-
Save publickeating/5096315 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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