バックボーン/アンダースコアを使用してオブジェクトのリストを出力しようとしていますが、バックボーンで奇妙な出力が得られます。解析されたデータ構造を期待していますが、ご覧のとおり、返されたものが正しい方法で解析されていないようです。何か案は?
これが私のjsonフィードです:
{"1":{"title":"Test Video Collection - blah (placeholder)","image":"imagenotavailable"},"2":{"title":"Camur Exerci Gemino","image":"public:\/\/gallery\/large\/imagefield_ieMdB8.jpg"},"3":{"title":"Abdo Nutus Sed","image":"public:\/\/gallery\/large\/imagefield_LtRKG1.png"},"4":{"title":"Quidne Vereor","image":"public:\/\/images\/video\/[current-date:custom:Y\/m\/d]\/imagefield_j7lGlq.jpg"},"5":{"title":"Ludus Ratis","image":"public:\/\/video-collections\/imagefield_aB3dpQ.png"},"6":{"title":"Appellatio Dolore Huic Vulputate","image":"public:\/\/gallery\/large\/imagefield_LtRKG1.png"}}
これが私のコードです:
var itemModel = Backbone.Model.extend();
var ItemList = Backbone.Collection.extend({
model: itemModel,
url: 'http://l.blahcouk.sandbox:8080/franchise/videocollection/date/'
});
var ItemsView = Backbone.View.extend({
template: _.template($('#bandlist_template').html()),
render: function (eventName) {
_.each(this.model.models, function (items) {
console.log(items);
var lTitle = items.attributes['title'];
var lTemplate = this.template(items.toJSON());
$(this.el).append(lTemplate);
}, this);
return this;
}
});
var lItems = new ItemList;
var AppView = Backbone.View.extend({
el: "body",
render: function () {
var lItemsView = new ItemsView({
model: lItems
});
var lHtml = lItemsView.render().el;
$('#bands').html(lHtml);
},
initialize: function () {
var lOptions = {};
lOptions.success = this.render;
lItems.fetch(lOptions);
}
});
var App = new AppView;
出力の構造は次のとおりです。
r {cid: "c2", attributes: Object, collection: r, _changing: false, _previousAttributes: Object…}
_changing: false
_events: Object
_pending: false
_previousAttributes: Object
attributes: Object
1: Object
2: Object
image: "public://gallery/large/imagefield_ieMdB8.jpg"
title: "Camur Exerci Gemino"
__proto__: Object
3: Object
4: Object
5: Object
6: Object
__proto__: Object
changed: Object
cid: "c2"
collection: r
__proto__: s