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

Allow CollectionView to be populated with pre-rendered DOM #3135

Merged
merged 4 commits into from
Aug 30, 2016

Conversation

paulfalgout
Copy link
Member

@paulfalgout paulfalgout commented Aug 19, 2016

https://jsfiddle.net/t29dkss1/1/

I don't really know if this would be considered breaking.. I don't really think so..

This will need tests.. thanks @rafde

Also one point to note.. overriding buildChildView was easy.. however that same function is used to build the emptyView which is kind of unfortunate.. it means that when an emptyView is built we're making an empty model to pass to this function.. and when you override it, we'll have to first detect if the view being passed is the childView or the emptyView before doing something out of the ordinary with the el.

If you were to override `buildChildView` instantiating the childViews with an `el` then you can create a collectionView from pre-rendered DOM
CollectionView can’t be initially “rendered” because it does its initialization of many things on first render.
@paulfalgout paulfalgout added this to the v3.x milestone Aug 19, 2016
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.841% when pulling fe6aa19 on pjf/collectionview-iso into f781dd9 on next.

@rafde
Copy link
Member

rafde commented Aug 19, 2016

looks reasonable. need help with the test?

@paulfalgout
Copy link
Member Author

sure thing. this branch is on the core, so you can commit right to it if ya want.

@rafde
Copy link
Member

rafde commented Aug 20, 2016

I'll git to it sometime today.

when a collection view is DOM
* and it's not attached to the document
** should have _isAttached set to false

* and it's attached to the document
** should have _isAttached set to true

when rendering a childView
* should not render childView twice
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 5d74ec1 on pjf/collectionview-iso into f781dd9 on next.

@@ -28,6 +28,34 @@ describe('collection view', function() {
// Collection View Specs
// ---------------------

describe('when a collection view is DOM', function() {
beforeEach(function() {
this.$fixtureEl = $('<div id="fixture-collectionview"></div>');
Copy link
Member

Choose a reason for hiding this comment

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

can we change the fixture to cater for when childViews are pre-rendered as well?

Copy link
Member

Choose a reason for hiding this comment

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

something like

this.$fixtureEl = $('<div id="fixture-collectionview"><span id="el1">1</span></div>');

this.view1 = new this.ChildView({el: this.$fixtureEl.find('#el1')[0]});

then

this.collectionView.addChildView(this.view1, 0);

although I haven't tried that addChildView nor do I know if it will work

Copy link
Member Author

Choose a reason for hiding this comment

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

it can also just be new this.ChildView({ el: '#el1' }); and I do think addChildView would work work.

when a collection view is DOM
* and it's not attached to the document
** should have a child view without `_isAttached`

* and it's attached to the document
** should have a child view with `_isAttached` set to `true`
@rafde
Copy link
Member

rafde commented Aug 24, 2016

@paulfalgout @ahumphreys87 updated.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 5034c32 on pjf/collectionview-iso into f781dd9 on next.

@ahumphreys87
Copy link
Member

Slightly related issue #2154

@rafde
Copy link
Member

rafde commented Aug 30, 2016

👍

2 similar comments
@denar90
Copy link
Member

denar90 commented Aug 30, 2016

👍

@scott-w
Copy link
Member

scott-w commented Aug 30, 2016

👍

@scott-w scott-w merged commit 8d41fc5 into next Aug 30, 2016
@paulfalgout paulfalgout modified the milestones: v3.1, v3.x Sep 28, 2016
@paulfalgout paulfalgout deleted the pjf/collectionview-iso branch March 6, 2017 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants