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 @flashes variable is passed as an option. So you must try something like this: console.log @this.options.flashes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With