jeudi 2 juin 2016

Backbone class properties? 'this.property' won't work in it's methods?

Help with Backbone needed:

var Vehicles = Backbone.Model.extend({}, {
    name: 'Sabre',
    summary: function() {
        console.log(this.name +" is a dog!");
    }
});

Vehicles.summary();

This prints out: " is a dog"

Two questions:

  1. Why doesn't it print out the name? Why doesn't this.name work?

  2. On the following line, what is the difference between firstBlock and secondBlock?

    Backbone.Model.extend({firstBlock},{SecondBlock});




Aucun commentaire:

Enregistrer un commentaire