开发者

Is it bad behaviour to put views inside models? (Backbone.js)

开发者 https://www.devze.com 2023-04-03 09:48 出处:网络
Hi i have a model that has models inside and inside... I need to give view to all of them and reach them in a hirearc开发者_运维问答hy.

Hi i have a model that has models inside and inside... I need to give view to all of them and reach them in a hirearc开发者_运维问答hy.

A Model
|
+---B Model
|   |
|   +----C Model
|   |
|   +----C Model
|
+---D Model

Think that all that models has views and for example when B models render function called i need to call both C models render functions.

So i decided that to create all related views inside models via overriding initialize methods.

So my question is that kind of behaviour is bad for mvc architecture? or it's natural?


I don't think models should know about views. It ought to be the other way 'round.

The view ought to be able to walk the model hierarchy, not the other way.

0

精彩评论

暂无评论...
验证码 换一张
取 消