Sha256: d33cd15e1f9db0062dc28f2d430b648382f415b42a9cb57ef376da593dbcf0e7

Contents?: true

Size: 615 Bytes

Versions: 8

Compression:

Stored size: 615 Bytes

Contents

<%= view_namespace %> ||= {}

class <%= view_namespace %>.IndexView extends Backbone.View
  template: JST["<%= jst 'index' %>"]

  initialize: () ->
    @options.<%= plural_model_name %>.bind('reset', @addAll)

  addAll: () =>
    @options.<%= plural_model_name %>.each(@addOne)

  addOne: (<%= singular_model_name %>) =>
    view = new <%= view_namespace %>.<%= singular_name.camelize %>View({model : <%= singular_model_name %>})
    @$("tbody").append(view.render().el)

  render: =>
    $(@el).html(@template(<%= plural_model_name %>: @options.<%= plural_model_name %>.toJSON() ))
    @addAll()

    return this

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails-backbone-0.8.0 lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-0.7.2 lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-0.7.1 lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-0.7.0 lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-0.6.1 lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-0.6.0 lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-0.6.0.rc lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-0.5.5 lib/generators/backbone/scaffold/templates/views/index_view.coffee