3

我有一个主干路由器

@collection = new Backbonedemo.Collections.Posts()
@flashes = new Backbone.Collection.Flashes()

在其initialize方法中。

在路由器的new方法中,有这样的:

new: ->
  view = new Backbonedemo.Views.PostsNew(collection: @collection, flashes: @flashes)
  $('#posts_container').html(view.render().el)

@collection变量传入就好了,但是在render()console.log @flashes返回undefined

那么,我错过了什么?

4

1 回答 1

5

@flashes变量作为选项传递。所以你必须尝试这样的事情:console.log @this.options.flashes

于 2012-10-21T09:53:09.510 回答