Created
April 23, 2011 20:12
-
-
Save tomdale/938930 to your computer and use it in GitHub Desktop.
How to override a label view render delegate
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
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