For the life of me, I can't figure out how to get a few attributes in my model.
I define my reportUrl model like this:
var ReportUrl = Backbone.Model.extend({
urlRoot: '/api/report/test/'
});
then in my view, I fetch it like this, and add it to my test model. Note - it only fetches one URL for each test:
var reportUrl = new ReportUrl({ id: test.id });
reportUrl.fetch();
test.set({
reportUrl: reportUrl
});
var view = new reportUrlView({
model: test
});
If I write it out, I can see it in my browser console(see the screenshot below). I just can't figure out how to access the data I need.
I need to get the serverUrl and reportExt attributes.
So I define 'this.reportUrl' like this: this.reportUrl = this.model.get('reportUrl');
if I do
console.log('this.reportUrl:', this.reportUrl);
But I've failed at all my attempts to get the attributes I need:
this.reportUrl.get('serverUrl') = undefined
this.reportUrl.serverUrl = undefined
this.model.attributes.reportUrl.get('serverUrl') = undefined
this.model.attributes.reportUrl.serverUrl = undefined
this.model.attributes.reportUrl.attributes.serverUrl = undfined
this is the only line that produced anything:
this.model.attributes.reportUrl.attributes = id: xxxxxx ^^ the test.id above
when I called new ReportUrl.
So is there anyway to access these attributes?
Thanks!