Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning collectionView on renderCollection(). #41

Merged
merged 3 commits into from Sep 3, 2014

Conversation

jrmyio
Copy link
Contributor

@jrmyio jrmyio commented Aug 14, 2014

To make it possible to track your model views of your collections. It is very handy to have a reference to the collectionView. Currently you can only use a syntax like this._subviews[1].views but this is rather hacky, nor do you exactly know what view it is.

By giving renderCollection() a return value of collectionView you can easily do
this.views = this.renderCollection();
_.each(this.views, function(view){});

Return collectionView in renderCollection()
@wraithgar
Copy link
Contributor

+1 This is a pretty easy change w/ minimal risk.

@lukekarrys
Copy link
Contributor

👍 With a small nitpick: I think we should mention it somewhere in the readme docs and example for renderCollection.

@wraithgar
Copy link
Contributor

If we document it, it needs to be enforced by a test

@HenrikJoreteg
Copy link
Member

We need a minor doc update saying the subview is returned and a simple test.

I'm a +1 once those are in place. Any core dev feel free to merge/publish this as a minor version once we have those in place.

@@ -350,6 +350,7 @@ _.extend(View.prototype, {
var collectionView = new CollectionView(config);
collectionView.render();
this.registerSubview(collectionView);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registerSubview actually returns the reference so this could just be:

return this.registerSubview(collectionView);

/me shrugs, either way. But there should be tests to make sure we don't accidentally change this behavior once implemented.

Just return this.registerSubview(collectionView);
lukekarrys added a commit that referenced this pull request Sep 3, 2014
Returning collectionView on renderCollection().
@lukekarrys lukekarrys merged commit 29d8e96 into AmpersandJS:master Sep 3, 2014
@lukekarrys
Copy link
Contributor

I'm going to merge this and update docs and add a test before publishing.

lukekarrys added a commit that referenced this pull request Sep 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants