试图让我的头绕过backbone.js,但是我碰到了一个绊脚石,因为我的测试代码不会显示任何东西。这包括我的console.log。 该页面能够读取json/js文件,并且不会产生任何错误我只剩下一件事。很难调试没有任何东西! 我可以处理的错误。Backbone/Underscore/JSON渲染问题
这里是我完整的代码(内嵌的时刻)
(function(){
var NewsModel = Backbone.Model.extend();
var NewsCollection = Backbone.Collection.extend({
model: NewsModel,
url : 'newsFeed.js'
});
var newsList = new NewsCollection();
newsList.fetch();
newsList.bind('reset', function() { console.log(newsList); });
var NewsView = Backbone.View.extend({
el : '.newsContainer ul',
template: _.template($('#NewsTemplate').html()),
initialize : function() {
this.render();
this.model.on('change', this.render, this);
},
render : function(eventName) {
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
}); }());
我使用谷歌驱动器作为一个试验场;链接为完整的HTML /代码。 https://docs.google.com/file/d/0B0mP2FImEQ6qa3hFTG1YUXpQQm8/edit [code View] https://googledrive.com/host/0B0mP2FImEQ6qUnFrU3lGcEplb2s/news.html [浏览器视图]
任何帮助,将不胜感激。我希望当我通过这个障碍,我会很好:)