stevew
stevew

Reputation: 734

Overriding member in Backbone views

I'm using Backbone.js to manage my views. I extend Backbone.View like so:

My.Views.PieChart = Backbone.View.extend({
    chartId: '',
    plot: {},
    params: {},
    legendLocation: 's',    // default value
    ...
    render: function() {
        console.log(this.legendLocation);
    }
});

Then I extend PieChart again to get the specific object.

My.Views.GenderChart = My.Views.PieChart.extend({
    chartId: 'gender',
    el: '#gender',
    legendPosition: 'e'
});

However, the GenderChart.legendPosition was still 's' when I call GenderChart.render()?

Thanks

Upvotes: 0

Views: 64

Answers (1)

Bholzer
Bholzer

Reputation: 189

Are you certain? Looks to me like the variables are two different names, and that might be causing the trouble. Do you actually want legendLocation and legendPosition or do you want to be overriding the legendLocation key in the superclass?

Upvotes: 1

Related Questions