未捕获的类型错误:对象#<LanPartys>没有方法'呼叫'
Uncaught TypeError: Object #<LanParties> has no method 'call'
我正在尝试循环遍历集合,并为集合中的每个模型渲染模板。我做错了什么?
顶层视图:
class App.Views.Content extends Backbone.View
className: 'views-container'
template: HandlebarsTemplates['app/templates/content']
render: ->
@$el.html(@template())
@renderEmptyView()
@renderLanParties()
@
renderEmptyView: ->
v = new App.Views.Empty()
@$('.content-wrapper').html(v.render().el)
renderLanParties: ->
v = new App.Views.LanParties({ collection: new App.Collections.LanParties })
@$('.lan-list').html(v.render().el)
视图渲染集合:
class App.Views.LanParties extends Backbone.View
className: 'lan-parties-list'
template: HandlebarsTemplates['app/templates/lan_parties']
initialize: ->
@listenTo @collection, 'reset', @render()
@collection.fetch({ reset: true })
render: ->
@$el.html(@template())
@collection.forEach @renderLanParty, @
@
renderLanParty: (model) ->
v = new App.Views.LanParty({ model: model })
@$('ul').append(v.render().el)
型号:
class App.Models.LanParty extends Backbone.Model
class App.Collections.LanParties extends Backbone.Collection
model: App.Models.LanParty
url: "/lan_parties"
在App.Views.LanParties中,不调用@render,更改
@listenTo @collection, 'reset', @render()
至
@listenTo @collection, 'reset', @render
您可能希望在App.Views.Content.中实例化新的App.Collections.LanPartys
相关文章:
- 在<页眉>标签
- 如何更改<svg>标记为<img>用js标记
- Ckeditor-plugin:插入虚假元素add不情愿<p>标签前后
- Ajax文件加载和<输入>文件加载
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 链接所有<a>Meteor
- 在<输入类型=“;文件“/>
- Div根据<选择>菜单
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- 如何首先设置样式<td>表中包含在窗体中的元素
- 通过点击<李>在jQuery中
- 正在检测导航到<a name=“;最新主题”></a>
- 如何更改<选择>使用angularJS从控制器获得的值
- 通过具有IE<11
- 如何附加<ul><李>元素位于某个特定条件的父元素列表之间
- 图像可以从源<img src=""/>.TEXT可以在没有javascript的情况下从外部
- 应为标识符,而看到'<'
- 如何设置默认<ui视图>在另一<ui视图>
- 使用Javascript,如何显示<tr>在另一<tr>悬停时,隐藏第二个<tr>
- 未捕获的类型错误:对象#<LanPartys>没有方法'呼叫'