2

我是骨干新手,尽管阅读了一些资源,但仍然有点不确定如何构建我的视图和相应的模型。

有问题的视图是一个自定义 facebook 视图,它在顶部有一个过滤器(下拉列表),然后在下面有一个内容视图 - 这取决于被过滤的内容会显示一些内容。

例如,您可以在过滤器中包含所有、状态、照片、组等项目。

如果用户选择全部,则内容视图应为用户呈现所有状态、照片和组更新。鉴于状态看起来与照片不同,视图应该能够以不同的方式呈现状态和照片。

如果用户选择状态,则仅显示状态列表。

问题是,我是为雕像、照片等创建单独的模型集合,还是只创建一个具有所有状态、照片等的多态集合模型?

景色怎么样?我应该创建不同的视图,一个用于显示所有项目,然后一个用于所选项目,还是应该只有一个视图并在其中有逻辑以根据模型以不同方式呈现事物?

谢谢!

4

1 回答 1

1

The way I would go about structuring the view would be.

ContainerView   (Holds dropdown and the content)
    |
    |
    |-----> HeaderView  (  This holds the Drop Dwon)
    |
    |-----> ContentView (This holds the content)
               |
               |
               |------> ListView ( For all the models )
                           |
                           |
                           |----> ListItemView ( Render each model in collection 

You would have a collections object that will be passed along to the Header and ContentView .

You list view will be listening to the reset and change event of your dropdown and render the list view that would iterate over the collection and render ListItemView for each model.

Now you have 2 approached to handle Photos , status and groups.

You can either have a attribute on each model that says the type of group it belongs to and have render a different template based on the attribute or you can have a separate view for each group. I would go with the latter ( might be a overkill ) . But it would be helpful if you are talking in terms of scalability and performance.

于 2013-06-25T00:29:47.167 回答