Sha256: b340f9bef3c6c4da876375a3253653c211828de42c131fef472a99177dad874d

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 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

1 entries across 1 versions & 1 rubygems

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