Created
May 17, 2010 20:32
-
-
Save ColinCampbell/404197 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
/* in views */ | |
sc_require('renderers/custom_list_item_renderer'); | |
MyApp.CustomListItem = SC.ListItemView.extend({ | |
createRenderer: function(theme) { | |
var ret = theme.customListItem(); | |
this.updateRenderer(ret); | |
return ret; | |
}, | |
// this may change, so it's more pluggable | |
// ie. I might implement a function that returns | |
// the attrs object and then that can be overriden | |
// rather than having two separate calls to renderer.attr() | |
// one here, and one in the super class | |
updateRenderer: function(renderer) { | |
sc_super(); | |
var attrs = { | |
isFoo: this.get('isFoo') | |
}; | |
renderer.attr(attrs); | |
} | |
}); |
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
/* in renderers */ | |
SC.AceTheme.renderers.CustomListItem = SC.BaseTheme.renderers.ListItem.extend({ | |
calculateClasses: function() { | |
var classes = sc_super(); | |
if (this.isFoo) classes['foo'] = YES; | |
return classes; | |
} | |
}); | |
SC.AceTheme.renderers.customListItem = SC.AceTheme.renderers.CustomListItem.create(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment