Blacksad
Blacksad

Reputation: 15442

Best practice with Backbone views: Reuse or create?

This question has been striking me for many days...

Let's say I have a very simple Backbone app with a list of items. When you click on an item, you see a detailed view of this item.

Is it better to

I prefer option 2, but there issues because I don't destroy the views properly, and get the infamous "ghost views" problem with events firing from nowhere !

What is the best practice ?

Upvotes: 8

Views: 2833

Answers (1)

Larry K
Larry K

Reputation: 49114

I re-use views in similar circumstances. Just reuse DetailedView. That way:

  • no need to create a structure to track all the views (since you wouldn't want to duplicate an already created view.)
  • No need to worry about memory size expanding without limit through long usage of the webapp

Upvotes: 2

Related Questions