The two console.logs in the code below show the following. The data objects are in json format with 'title', 'position' and 'content'. However, I'm not sure how to view data in a console.log. For example, I tried console.log("data " + data[0].title)
to get the title of the first data object, but it returned undefined. As for the 'this' object, I don't actually know what it is. This is the initialize function in a router view of a backbone app, which I'm trying to deconstruct but I can't figure out what 'this' is in this context.
**this** [object Object]
**data** [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
code
initialize: function (options)
{
var _this = this;
console.log("this " + this);
$.ajax({
url: "json/Backboneapp_data.json",
dataType: 'json',
data: {},
async: false,
success: function (data)
{
console.log("data " + data)
_this._data = data;
_this._items = new ItemCollection(data);
_this._view = new MenuView({ model: _this._items });
_this._view.render();
Backbone.history.loadUrl();
}
});
return this;
},