Unexpectedly, the following code will print Test1 undefined instead of Test1 Test2.
var MyView = Backbone.View.extend({
initialize: function () {
console.log(this.collection, this.test);
}
});
new MyView({collection: "Test1", test: "Test2"});
What am I doing wrong?
Only the following properties from the options argument get merged in as view properties.
Any other property gets placed on the options property of the view.
So to access the test property from the initialize method, you can update your code as follows.