0
votes

I have a composite view which has a task, and it's comments. I put it onto a contentRegion to display. When rendering model alone, it works fine. However when come to collection, it behaves really strange. console.log shows initialize function has been triggered twice. The first time is when define the view

taskView = new MyProject.Views.Task
  model : task
  collection : comments

I then do a MyProject.contentRegion.show(taskView) in order to render the model view. After that, I just call comments.fetch() to get all the comments. Then comes the problem, it re-initialized my taskView and the template keep complaining xxx is undefined.

Any thoughts? I know it's weird because another CompositeView in my project works great.

1
post more code, please. there isn't enough here to know what's going on. What is "MyProject.Views.Task" for example? - Derick Bailey
I'm having almost exactly the same problem. I will start a new question - Thomas Hudspith-Tatham
@ThomasHudspith-Tatham I ended up using an itemview and loop adding the collection manually. - yujingz

1 Answers

1
votes

NathanInMac, I've done a little testing from your suggestion of using an itemView and found some interesting stuff.

Was your problem involving nested compositeviews'? As mine was but I'm unsure if that affects anything.

What solved the problem was initially trying a collectionView which couldn't find the itemView so I moved the definition of the itemView for the collectionView/compositeView to before the definition of the collectionView(or extended).

This seems to be a working fix and just a misleading bug with compositeView's double initializing instead of displaying some exception or error.