How Do I Pass Properties To A Backbone View?
I was developing my app using Backbone v1.0.0 and between beginning work and now there has been an update to v1.1.0. So where I used to be able to do, var myView = new MyView({hash
Solution 1:
From the 1.1.0 ChangeLog:
- Backbone Views no longer automatically attach options passed to the constructor as
this.options, but you can do it yourself if you prefer.
So the constructor options are still passed to initialize but this.options is no longer automatically set up. You can do this:
initialize: function(options) {
// Stash `options.hash` in `this` if you want or// `this.options = options;` if you want to emulate// the old behavior.
}
Demo: http://jsfiddle.net/ambiguous/SaJkz/
Post a Comment for "How Do I Pass Properties To A Backbone View?"