Skip to content

Instantly share code, notes, and snippets.

@tomdale

tomdale/gist:938930

Created Apr 23, 2011
Embed
What would you like to do?
How to override a label view render delegate
labelView: SC.LabelView.design({
layout: { centerX: 0, centerY: 0, width: 200, height: 18 },
textAlign: SC.ALIGN_CENTER,
tagName: "h1",
value: "Welcome to SproutCore!",
// Adds 'didClick' as a display property
displayProperties: ['didClick'],
didClick: NO,
// Override the render delegate object
renderDelegate: SC.BaseTheme.labelRenderDelegate.extend({
update: function(dataSource, $) {
if (dataSource.get('didClick')) {
$.css('border', '2px solid red');
}
return sc_super();
}
}),
click: function() {
this.set("value", "Changed!");
this.set('didClick', YES);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment