Skip to content

Instantly share code, notes, and snippets.

@tomdale
Created April 23, 2011 20:12
Show Gist options
  • Save tomdale/938930 to your computer and use it in GitHub Desktop.
Save tomdale/938930 to your computer and use it in GitHub Desktop.
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