Skip to content

Instantly share code, notes, and snippets.

@icai
Created July 31, 2014 01:55
Show Gist options
  • Save icai/5d1fb280795ff40ada5e to your computer and use it in GitHub Desktop.
Save icai/5d1fb280795ff40ada5e to your computer and use it in GitHub Desktop.
Backbone.View.inject
Backbone.View.prototype.inject = function(viewOptions,options){
var offcialViewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
viewOptions = _.filter(viewOptions,function(item){
return !~_.indexOf(offcialViewOptions,item)
})
_.extend(this, _.pick(options, viewOptions));
}
// view.inject(['modal'],{modal:modal}) demo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment