Sha256: 09a31bb2f9c0ce9362fdcd666b2bf28a88cdbb69e927455679eaf119ad7fd5d8

Contents?: true

Size: 732 Bytes

Versions: 1

Compression:

Stored size: 732 Bytes

Contents

App.<%= @controller_name.camelize %>.Index.List = class List extends Spine.Controller

  constructor: ->
    <%= @model_name.camelize %>.bind "refresh", @addAll
    <%= @model_name.camelize %>.bind "select", @select
    <%= @model_name.camelize %>.bind "deselect", @deselect
    super
    @itemClass = App.<%= @controller_name.camelize %>.Index.Item
    @children = {}

  render: ->
    <%= @model_name.camelize %>.fetch()
    @

  addAll: (items) =>
    @addOne(item) for item in items

  addOne: (item) ->
    controller = new @itemClass(item: item)
    @children[item.id] = controller
    @append controller.render().el

  select: (item) =>
    @children[item.id].select()

  deselect: (item) =>
    @children[item.id].deselect()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
space_frame_spine-0.0.5 lib/generators/section/templates/app/controllers/%controller_name%/index/list.coffee.tt