Created
July 31, 2014 01:55
-
-
Save icai/5d1fb280795ff40ada5e to your computer and use it in GitHub Desktop.
Backbone.View.inject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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