有点奇怪...
我有收藏:
class Store.Collections.Product extends Backbone.Collection
url: '/api/products'
model: Store.Models.Product
有观点:
class Store.Views.Origin extends Backbone.View
initialize: ->
@collection = new Store.Collections.Product()
@collection.fetch()
@model.bind('change:formatted', @render, this);
@render()
events:
'change [name=origin]': 'setOrigin'
el: =>
@options.parent.$('.origin-input')[0]
template: JST["backbone/templates/shapes/product"]
render: ->
$this = $(this.el)
$this.html(@template(model: @model.toJSON(), errors: @model.errors))
console.log(@collection)
@collection.each(@appdenDropdown)
@delegateEvents()
this
appdenDropdown: (product) ->
console.log("append trigger")
#view = new Store.Views.Products(model: product)
#$('#history').append(view.render().el)
使用模板:
<div id="history"></div>
该系列作品...
console.log(@collection)
显示数据!然而
@collection.each(@appdenDropdown)
不做任何事情,不出错,或通过任何事情。它只是没有做任何事情。我正在尝试从集合中提取数据!但它不会...