-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ function View(attrs) { | |
} | ||
this._initializeSubviews(); | ||
this.initialize.apply(this, arguments); | ||
this.set(_.pick(attrs, viewOptions)); | ||
if (this.autoRender && this.template) { | ||
this.render(); | ||
} | ||
|
@@ -76,9 +75,7 @@ var BaseState = State.extend({ | |
|
||
// Cached regex to split keys for `delegate`. | ||
var delegateEventSplitter = /^(\S+)\s*(.*)$/; | ||
|
||
// List of view options to be merged as properties. | ||
var viewOptions = ['model', 'collection', 'el']; | ||
var excludedSubviewOpts = ['container', 'hook', 'waitFor']; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
View.prototype = Object.create(BaseState.prototype); | ||
|
||
|
@@ -257,10 +254,20 @@ _.extend(View.prototype, { | |
selector: subview.container || '[data-hook="' + subview.hook + '"]', | ||
waitFor: subview.waitFor || '', | ||
prepareView: subview.prepareView || function (el) { | ||
return new subview.constructor({ | ||
var opts = { | ||
el: el, | ||
parent: self | ||
}); | ||
}; | ||
// pass in parent's model/collection by default | ||
opts.model = self.model; | ||
opts.collection = self.collection; | ||
// allow arbitrary paths to be passed through to child | ||
for (var key in subview) { | ||
if (!_.contains(excludedSubviewOpts, key) && typeof subview[key] === 'string') { | ||
This comment has been minimized.
Sorry, something went wrong.
pgilad
Member
|
||
opts[key] = getPath(this, subview[key]); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
HenrikJoreteg
Author
Member
|
||
} | ||
} | ||
return new subview.constructor(opts); | ||
} | ||
}; | ||
function action() { | ||
|
selector
,constructor
?