src/components/collection_view.coffee in luca-0.9.0 vs src/components/collection_view.coffee in luca-0.9.1

- old
+ new

@@ -23,11 +23,11 @@ _.bindAll @, "refresh" unless @collection? throw "Collection Views must specify a collection" - unless @itemTemplate? || @itemRenderer? + unless @itemTemplate? || @itemRenderer? || @itemProperty? throw "Collection Views must specify an item template or item renderer function" Luca.components.Panel::initialize.apply(@, arguments) if Luca.isBackboneCollection(@collection) @@ -36,26 +36,29 @@ @collection.bind "remove", @refresh attributesForItem: (item)-> _.extend {}, class: @itemClassName, "data-index": item.index - # expects an item object, which contains the contentForItem: (item={})-> if @itemTemplate? and templateFn = Luca.template(@itemTemplate) content = templateFn.call(@, item) if @itemRenderer? and _.isFunction( @itemRenderer ) content = @itemRenderer.call(@, item) - content || "" + if @itemProperty + content = if _.isFunction(@itemProperty) then @itemProperty() else (item.model.get(@itemProperty) || item.model[ @itemProperty ]) makeItem: (model, index)-> item = if @prepareItem? then @prepareItem.call(@, model, index) else (model:model, index: index) make(@itemTagName, @attributesForItem(item), @contentForItem(item)) getModels: ()-> - @collection.models + if @collection?.query and (@filter || @filterOptions) + @collection.query(@filter, @filterOptions) + else + @collection.models refresh: ()-> panel = @ @$bodyEl().empty() \ No newline at end of file