var ListView = Backbone.View.extend({
el: $('hello'),
initialize: function() {
var stuff = new FieldCollection();
var output;
stuff.parse();
stuff.fetch({
success: function (collection, response) {
console.log(response);
output=response;
return response;
}
});
this.render(output);
},
render:function(output){
console.log(output);
$(this.el).append("<button id='add'>hiii</button>");
$(this.el).append("<button id='removeAll'>Remove all list item</button>");
}
});
在这里,我试图抓住在output
变量响应的价值......但它的未来“未定义”。任何想法,我错了?取结果是不确定的(Backbone.js的)
有了这些信息,我可以推断出大量的问题。服务器是否返回正确的json? 'fetch'后服务器是否返回任何东西?你是否在'success'回调中尝试'console.log(arguments)'来确保你正在接收多个参数? – Deeptechtons