Sha256: d297626a4702d5d58cd457a30ba9cd0d9f3180829e604ca25ea1bcfab28c04fe

Contents?: true

Size: 756 Bytes

Versions: 15

Compression:

Stored size: 756 Bytes

Contents

$ ->
  PostsApp.PostsIndexView = Backbone.View.extend
    initialize: ->
      _.bindAll(this, 'addPost', 'addAllPosts', 'removePost')
      PostsApp.Posts.on('add', this.addPost, this)
      PostsApp.Posts.on('remove', this.removePost, this)
      PostsApp.Posts.on('reset', this.addAllPosts, this)

    template:
      JST["crowdblog/templates/posts/index"]

    render: ->
      this.$el.html(this.template())
      this

    addPost: (post) ->
      elementId = 'post-' + post.id
      post_view = new PostsApp.PostView
        model: post
        id: elementId

      this.$el.find('tbody').append(post_view.render().el)

    addAllPosts: ->
      PostsApp.Posts.each(this.addPost)

    removePost: (post) ->
      this.$('#post-' + post.id).remove()

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
crowdblog-0.0.16 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.15 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.14 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.13 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.12 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.10 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.9 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.8 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.7 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.6 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.5 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.4 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.3 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.2 app/assets/javascripts/crowdblog/views/posts/index.js.coffee
crowdblog-0.0.1 app/assets/javascripts/crowdblog/views/posts/index.js.coffee