Backbone.js를 배우기 시작했으며 컬렉션으로 첫 번째 앱을 작성하려고했습니다.backbone.js - 정의되지 않은 함수가 아닙니다.
console.clear();
(function($){
window.App = {
Models : {},
Collections : {},
Views : {}
};
//a single estimate
App.Models.Estimate = Backbone.Model.extend({});
// multiple esitmates
App.Collections.Estimates = Backbone.Collection.extend({
model : App.Collections.Estimate
});
App.Views.Estimates = Backbone.View.extend({
tagName: 'ul',
render : function(){
this.collection.each(this.addTo,this);
},
addTo:function(estimate){
var dir = App.Views.Estimate({model:estimate}).render();
this.$el.append(dir.el);
}
});
App.Views.Estimate = Backbone.View.extend({
tagName: 'li',
render :function(){
this.$el.html(this.model.get('title'));
return this;
}
});
var jSon = [{title:'Abhiram', estimate:8}];
var estimates = new App.Collections.Estimates(jSon);
console.log(estimates);
var tasksView = new App.Views.Estimates({collection:estimates});
// var a = tasksView.render().el;
//console.log(a);
})($j||jQuery);
나는 모든 세 가지가 포함 시켰습니다 :
jQuery를 먼저 밑줄 다음과 백본 여기에 코드입니다. 나는 계속 "Undefined is not function"을 얻고 있습니다. 내가 잘못하고 있다면 알려주십시오.
감사합니다.
오류를 생성하는 행을 찾을 수 있습니까? – Floris
'App.Models.Estimate = Backbone.Model.extend ({});는'App.Models.Estimate = Backbone.Model; '과 같습니다. –
예, 그랬습니다. 고맙습니다. – abhididdigi