I have a backbone router that has
@collection = new Backbonedemo.Collections.Posts()
@flashes = new Backbone.Collection.Flashes()
in its initialize method.
In the router’s new method, there’s this:
new: ->
view = new Backbonedemo.Views.PostsNew(collection: @collection, flashes: @flashes)
$('#posts_container').html(view.render().el)
The @collection variable passes in just fine, but in render(), console.log @flashes returns undefined.
So, what am I missing?
The
@flashesvariable is passed as an option. So you must try something like this:console.log @this.options.flashes