Code:
Ext.define('Pegfect.model.QuestionSet', {
questions: [],
skippedFromQuestionSetIndex: undefined,
push: function (question) {
this.questions.push(question);
},
getCount: function() { return this.questions.length; },
first: function () { return this.questions[0]; },
getAt: function(index) { return this.questions[index]; },
getSubDimension: function () { return this.first().subDimension; },
getSubDimensionText: function () { return this.getSubDimension().get('Text'); },
getSubDimensionId: function () { return this.getSubDimension().getId(); }
});
var currentQuestionSet;
this.rootDimension.subDimensions().each(function (subDimension) {
//subDimension.questions().filterBy(function (question) { if (question.hidden == false) return question; });
subDimension.questions().each(function (question) {
if (question.hidden) return true;
if (!question.get('GroupWithPrevious')) {
currentQuestionSet = Ext.create('Pegfect.model.QuestionSet');
me.questionSets.push(currentQuestionSet);
qSetCount++;
}
currentQuestionSet.push(question);
qCount++;
question.subDimension = subDimension;
});
});
The call to Ext.create('Pegfect.model.QuestionSet'); returns the same instance previously created with the questions array containing questions previously added to previous instances.
Why?