Skip to content

Instantly share code, notes, and snippets.

@fiznool
Created June 6, 2013 09:19
Show Gist options
  • Save fiznool/5720342 to your computer and use it in GitHub Desktop.
Save fiznool/5720342 to your computer and use it in GitHub Desktop.
Overriding Backbone Constructor.
Backbone.View.extend({
constructor: function (options) {
// Do stuff before the View has been setup
Backbone.View.apply(this, arguments);
// Do stuff after the View has been setup,
// particularly after `initialize()` has been called
return this;
}
});
@ORESoftware
Copy link

don't return this!!! you aren't supposed return things from constructors, in fact they should fail if you do

@ORESoftware
Copy link

also technically this is just extending the constructor, you are not overriding it because you are calling the original constructor

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