As I work on my app using backbone, I'm encountering a challenge that might be due to a misunderstanding on my part.
I am trying to set specific attributes like titles while also having default values in place. However, it seems that the custom attributes are not being properly applied. Why could this be?
var DataMapper = {
Models: {},
Collections: {},
Views: {},
Templates: {}
};
DataMapper.Views.OperatorView = Backbone.View.extend({
el: "#op-panel",
operators: [],
events: {
"click #concat-op-btn": "addConcatOp"
},
addConcatOp: function() {
var concatOperator = new DataMapper.Models.OpContainerBox({title: "Concat", inputCount: 2, outputCount: 1});
this.operators.push(concatOperator);
concatOperator.drawContainer();
}
});
DataMapper.Models.OpContainerBox = Backbone.Model.extend({
title: "Operator",
inputCount: 0,
outputCount: 0,
defaults: {
x: 400,
y: 40,
leaves: [],
height: 20,
width: 120
},
drawContainer: function() {
console.log(this.title); //outputs "Operator" instead of "Concat"
}
});
new DataMapper.Views.OperatorView();