Created
September 9, 2009 03:33
-
-
Save geoffreyd/183455 to your computer and use it in GitHub Desktop.
What a settable and gettable computed function should look like
This file contains hidden or 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
firstName: SC.Record.attr(String), | |
lastName: SC.Record.attr(String), | |
fullName: function(key, newValue) | |
{ | |
if(newValue) { | |
var names = newValue.split(" "); | |
this.set('firstName', names[0]); | |
this.set('lastName', names[1]); | |
return this; | |
} | |
return this.get('firstName')+" "+this.get('lastName'); | |
}.property('firstName','lastName').cacheable() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment