Skip to content

Instantly share code, notes, and snippets.

@charlesjolley
Created October 26, 2010 19:39
Show Gist options
  • Save charlesjolley/647617 to your computer and use it in GitHub Desktop.
Save charlesjolley/647617 to your computer and use it in GitHub Desktop.
Renderers Middle Ground?
// RenderDelegates are a part of jQuery so they are reusable.
var del = SC.RenderDelegate.extend({
enable: function(flag) {
this.setClass('enabled', YES); // used buffered jQuery to build up changes
},
active: function(flag) {
this.setClass('active', YES);
}
});
MyApp.ButtonView = SC.CoreView.extend({
renderDelegate: del,
isEnabled: YES,
isEnabledDidChange: function() {
this.get('renderDelegate').enable(this.get('isEnabled')); // buffers...
},
// this would be our generic render code...
render: function(ctx, firstTime) {
if (firstTime) this.get('renderDelegate').render(ctx);
else this.get('renderDelegate').update(ctx);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment