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
- Message_Title 1 in THREAD_A
- Message_Title 2 in THREAD_B
- Message_Title 3 in THREAD_A
- Message_Title 4 in THREAD_B
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!