-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
CompositeView attempts to appendHtml of itemViews before itemViewContainer exists (before template is rendered) #533
Conversation
Aha, the reason it was working in another part of my application is because I had a custom |
This commit seems to attempt to fix the problem, but I had to go a little bit further and check that the Glad I'm finally getting to the bottom of this. One thing is for sure, it has improved my JS debugging skills! Sorry I couldn't submit a spec for this. |
AHA! good catch, and totally makes sense now that you point it out. Will get this pulled in w/ a spec, along with some other bug fixes, ASAP. |
It does cause quite a few specs to fail, hope you can work around that! |
Hi everyone. Before you apply this fix: So i added renderItemView method with isRendered condition to CompositeView class. And now it works fine. I hope it can help you. |
@atorian Could you make a PR, and reference it here? I would be grateful to see your solution and it makes it easier for @derickbailey to just merge. |
I think a much cleaner solution is the one proposed by @b4cedev in #377 - binding to collection events only after the CompositeView has been rendered: _initialEvents: function(){
this.once('render', function () {
if (this.collection){
this.listenTo(this.collection, "add", this.addChildView, this);
this.listenTo(this.collection, "remove", this.removeItemView, this);
this.listenTo(this.collection, "reset", this._renderChildren, this);
}
}, this);
}, This way we avoid unnecessary calculations in all methods starting from |
Thanks @lukaszfiszer and @b4cedev ! That's exactly what I needed. |
closing |
When this fix will be in the upstream? |
👍 Need this one too, it should be re opened, no ? |
I like @lukaszfiszer solution, anyone want to take a stab at opening a PR with this fix? |
I can submit a PR during this weekend. |
I have a
CompositeView
which takes a model (already downloaded from server) and a collection which is then fetched. As soon as thesync
is finished, I want to render my CompositeView. However, the CompositeView appears to try appending the itemViews for the collection before it renders its own template, and so it can't find its ownitemViewContainer
, generating errorUncaught ItemViewContainerMissingError: The specified
itemViewContainerwas not found: .modal__body
.Here is a gist.
I should note that I have exactly the same setup elsewhere and it works with no problems, so it could well be something on my end, but I've spent long enough debugging this one and I can't seem to find the problem!