Sha256: 78ce83480bccc535f5c6693bace052ece5fd85feabee49263e3d356eaaf94d25

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

<%= view_namespace %> ||= {}

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

  initialize: () ->
    _.bindAll(this, 'addOne', 'addAll', 'render')

    @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

2 entries across 1 versions & 1 rubygems

Version Path
rails-backbone-sp-0.0.1 lib/generators/backbone/scaffold/templates/views/index_view.coffee
rails-backbone-sp-0.0.1 lib/generators/backbone/scaffold/templates/views-sp/index_view.coffee