you can access View’s model from the View methods – like render() (through its model property). But let’s say you have many different models and use the them with the same type of View, changing view’s model property when you need.
How can you determine from the View what type of the model it’s using?
var Model1 = Backbone.Model.extend();
var Model2 = Backbone.Model.extend();
var MyView = Backbone.View.extend({
render:function(){
console.log(" you're using: "+ model); // how to determine here is it using Model1 or Model2
}
})
var mv1 = new MyView({model: new Model1()})
var mv2 = new MyView({model: new Model2()})
Keeping this simple…