Created
October 26, 2010 19:39
-
-
Save charlesjolley/647617 to your computer and use it in GitHub Desktop.
Renderers Middle Ground?
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
// 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