1
User = Backbone.Model.extend({
urlRoot: "users",
initialize: function(){
this.fetch();
}
});
var HomeView = Backbone.View.extend({
el: '#container',
template: _.template($("#home-template").html(), this.model),
render: function() {
$(this.el).html(this.template);
return this;
}
});
var App = Backbone.Router.extend({
routes: {
'/home': 'home',
},
home: function() {
var user = new User({id: 1});
homeView = new HomeView({
model: user
});
this.homeView.render();
}
});
어떤 이유로 든 모델 데이터를 HomeView 템플릿에 삽입 할 수 없습니다. 아약스 요청을 보냈고 다시 오는 데이터가 맞습니다. 뷰를 호출 할 때 정적 데이터를 같은 위치에 놓았고 정상적으로 작동했습니다.Backbone.js - json 데이터를보기로 가져옴
제안 사항?
정확히 그랬습니다. 감사! – user577808