zloctb
zloctb

Reputation: 11177

What's differences between ItemView and View in marionette?

Version 2.x had many different kinds of views: View, ItemView, LayoutView, CollectionView, CompositeView.

In version 3 ItemView, and LayoutView were ‘merged’ into View, and CompositeView was deprecated for removal in v4. Now we have only View and CollectionView.

What's differences between ItemView and View in marionette 2 ?

If I replace all my ItemView to View in my code in Marionette 3 ? How will I get problems ?

Upvotes: 0

Views: 567

Answers (1)

What's differences between ItemView and View in marionette 2 ?


Ok, in older version Marionette we created chosen instance view by use specific class name.
So. if you want create itemView you should use ItemView class, or if you want layout view instance you use LayoutView class. Each view class inherits from basic View class, so each views have common attributes, but not all.

Therefore ItemView is is a special case of View. In M2 create view's instance isn't recommended using direct by View class

In Marionette 3 you Don't have to indicate specific class because View class is a more detailed. Depending on defined attributes your view can be a itemView or layoutView

var view = new Marionette.View({ template: "#some-template"});

//So we can say that is a normal itemView
var layoutView = new Marionette.View({ 
  template: "#some-template",
  regions: {
    menu: "#menu",
    content: "#content"
  });

//So we can say that now is a layoutView, because we defined a regions.

Of course CollectionView has own class as in the previous version.

If I replace all my ItemView to View in my code in Marionette 3 ? How will I get problems ?

No, in this case you shouldn't have any problems.

Upvotes: 2

Related Questions