Skip to content

Instantly share code, notes, and snippets.

View vangie's full-sized avatar

Vangie Du vangie

View GitHub Profile
@vangie
vangie / extending-the-defaults-of-a-model-superclass-in-backbone-js
Created June 23, 2012 18:06
Extending the defaults of a Model superclass in Backbone.js
var ExtendedInventory = Inventory.extend({
defaults: {
rabit:25
}
});
_.extend(ExtendedInventory.prototype.defaults, Inventory.prototype.defaults);
// or
@vangie
vangie / gist:2592085
Created May 4, 2012 04:43
how to implement this._super in js function
// tests if we can get super in .toString()
fnTest = /xyz/.test(function() {
xyz;
}) ? /\b_super\b/ : /.*/,
// overwrites an object with methods, sets up _super
// newProps - new properties
// oldProps - where the old properties might be
// addTo - what we are adding to
inheritProps = function( newProps, oldProps, addTo ) {