我决定进入 Backbone 竞技场,在搜索了 BB 和 Marionette 的文档后,我在看似简单的事情上遇到了一些麻烦。
我只是想自定义第三条记录上显示的内容。
以下是我将如何使用 Rails
    <% @posts.each_with_index do |post, i| %>
      <% if i == 1 || i == 7 || i == 14 %><!-- 1st, 7th, & 14th record -->
        display title, description & something else
      <% else %><!-- other records -->
        display only title
      <% end %>
    <% end %>
使用 Backbone + Marionette + Underscore,这是我的记录的显示方式: 控制器
        postsRegion: (posts) ->
            postsView = @getPostsView posts
            postsView.on "childview:posts:post:clicked", (child, post) ->
                App.vent.trigger "posts:post:clicked", post
            @layout.postsRegion.show postsView
        getPostsView: (posts) ->
            new List.Posts
                collection: posts
看法
   class List.Post extends App.Views.ItemView
        template: "posts/list/_post"
        tagName: "li"
        className: "span4 item"
        events:
            "click" : -> @trigger "posts:post:clicked", @model
如何使第 1、7 和第 14(或仅第三)记录显示不同的内容?另外,作为一名设计师,任何人都可以建议使用这个 js 库进一步阅读视图吗?