Skip to content

Instantly share code, notes, and snippets.

@nakamura-to
Created December 20, 2012 07:52
Show Gist options
  • Save nakamura-to/4343626 to your computer and use it in GitHub Desktop.
Save nakamura-to/4343626 to your computer and use it in GitHub Desktop.
Intercepting the Backbone.View initialize method.
var _View = Backbone.View;
Backbone.View = function () {
logger.info('before');
var init = this.initialize;
if (init) {
this.initialize = function () {
logger.info('before initialize');
init.call(this);
logger.info('after initialize');
}.bind(this);
}
_View.apply(this, arguments);
logger.info('after');
};
Backbone.View.prototype = _View.prototype;
Backbone.View.extend = _View.extend;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment