I am using Backbone Relational to handle relationships between two models that I have. Here are the two models that I have:
Thread = Backbone.RelationalModel.extend({
urlRoot: '/api/thread',
idAttribute: '_id',
relations: [{
type: Backbone.HasMany,
key: 'messages',
relatedModel: 'Message',
reverseRelation: {
key: 'collection',
includeInJSON: '_id',
},
}]
});
The other model is:
Message= Backbone.RelationalModel.extend({
url: '/api/message',
});
Thread has an attribute called thread_name. This means that JSON of collection will be like
thread_name, messages: [message_title]
Now, I want a view like this
Now the question, how will be the View? This means, how can I access parent attribute name (i.e. ThreadName) in a Message_View?
P.S. : I am learning from the tutorial here http://antoviaque.org/docs/tutorials/backbone-relational-tutorial/
Please help!
have you tried (model.__super__) ?, this is supposed to get the parent model from which you extend. I am not sure about 'RelationalModel' and too lazy to do a jsfiddle!