문제점이 확실하지 않습니다. 관심사를 분리하기 위해 컬렉션 클래스를 약간 다시 작성하면 완벽하게 유효한 모델을 얻을 수 있습니다.
Shot = Backbone.Model.extend({
initialize:function(opts) {
console.log("init shot : "+opts.id);
}
});
ShotsList = Backbone.Collection.extend({
model: Shot,
sync: function(method, model, options) {
var params = _.extend({
type: 'GET',
dataType: 'jsonp',
url: model.url(),
processData: false
}, options);
return $.ajax(params);
},
parse: function(response) {
return response.shots;
},
url: function() {
return "http://api.dribbble.com/players/" + encodeURIComponent(this.player) + "/shots?per_page=18";
}
});
s=new ShotsList();
s.bind("reset",function(collection) {
console.log(collection.models);
console.log(collection.pluck("image_teaser_url"));
});
s.player="jordan";
s.fetch();
감사합니다. 나는 그 문제가 무엇 인지도 모르겠다. 그러나 당신이 그들을 가지고있는 것처럼 이것을 재배치 한 후에 그것은 작동하는 것처럼 보였던 다른 약간의 비트를 정리했다. 다시 한번 감사드립니다. – mattl