Skip to content

Instantly share code, notes, and snippets.

@erichocean
Created December 15, 2010 00:58
Show Gist options
  • Save erichocean/741440 to your computer and use it in GitHub Desktop.
Save erichocean/741440 to your computer and use it in GitHub Desktop.
proof-of-concept: allows you to write <key>Update: functions instead of putting all your code inside update()
// Add this to your custom view or render delegate (see comment below for the rest).
update: function(jquery) {
var fn, key, displayProperties = this.getChangedDisplayProperties() ;
for (key in displayProperties) {
if (!displayProperties.hasOwnProperty(key)) continue ;
if (fn = this[key+'Update']) fn.call(this, jquery, displayProperties[key]) ;
}
}
@erichocean
Copy link
Author

Example usage:

displayProperties: 'title value'.w(),
titleUpdate: function($, val) { $.find('.title').text(val); },
valueUpdate: function($, val) { $.find('.value').text(val); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment