I'd like to have the following. Imagine you have a homework assignment that has several problems and a grade. Each problem has several parts and a level of difficulty. Each part has an attribute right or wrong.
I'd like to implement that logic through nested models (or really however you can do it, this is just my best guess). So there would be a model 'part' which has an attribute right or wrong. Then there would be a model called problem which has several parts associated with it (a collection? not sure if this is possible) and an attribute difficulty. Then you would have a model homework which would have several problems associated with it and an attribute grade.
My question is:
Is this possible? If so, what is the syntax for your general model creation? What's the syntax for rendering this?
I'm looking for something general like this:
var Homework=Backbone.model.extend({
defaults:{
grade:100,
parts: var parts=Backbone.model.extend({ .... //this definitely seems wrong });
},
});
var Homeworkview=Backbone.view.extend({
initialize: function(){
//create one question with one part
},
render: function(){
//render template for homework grade then call function to render question, which then renders parts},
});
So how do you do this?