나는 백본을 사용하여 응용 프로그램을 가지고 있지만 내가 컬렉션의 fetch()
메소드를 호출 할 때마다 그것은 정의되지 않은 반환백본 - 컬렉션 가져 오기가 정의되지 않은 값을 반환합니까?
// App
(function() {
window.app = {};
app.collections = {};
app.models = {};
app.views = {};
$(function() {
app.collections.complaintTypes = new app.collections.ComplaintTypesCollection();
app.views.complaintTypesView = new app.views.ComplaintTypesView({ collection: app.collections.complaintTypes });
});
})();
// Collections
(function (collections, model) {
collections.ComplaintTypesCollection = Backbone.Collection.extend({
initialize: function() {
this.fetch();
},
model: model,
url: '/api/ComplaintTypes'
});
})(app.collections, app.models.ComplaintType);
// Models
(function (models) {
models.ComplaintType = Backbone.Model.extend({
idAttribute: 'ComplaintTypeId'
});
})(app.models);
// Views
(function (views) {
views.ComplaintTypesView = Backbone.View.extend({
initialize: function() {
this.collection.on('reset', this.render, this);
},
render: function() {
console.log(this.collection);
}
});
})(app.views);
하지만 아무것도 반환하지 않습니다? 피들러를 사용하고 내 URL :/api/ComplaintTypes로 이동하면 데이터가 다시 검색되므로 어떤 일이 잘못되었는지 잘 모르겠습니다.
정확하게 오류 메시지는 무엇입니까? 이 코드는 오류를 생성하는 코드 행과 정확히 일치합니까? – fguillen
오류는 다음과 같습니다. '잡히지 않은 유형 오류 : 정의되지 않은 함수입니다 .' 코드 줄이 Backbone.js 줄에 있습니다. 815 – CallumVass
JavaScript 콘솔을 사용하여 _backtrace_ 오류를 확인하고 해당 코드의 첫 줄을 찾습니다. 목록에 있습니다. – fguillen