我调用了一个视图(menuview),将它传递给了一个 var(prova),但从视图中调用它的结果是未定义的(console.log(this.model),在 menuview 中)。有人可以帮我找出错误吗?
路由器
home: function() {
new BarraScreamView();
new MenuView();
var self=this;
var amicizie= new Amicizie();
amicizie.fetch({
success: function(object) {
console.log(object);
var prova=object.where({invitante: Parse.User.current().id,conferma:0});//mettere
invitato
var num=prova.length;
new MenuView({model:prova});<<<---------
},
error: function(amici, error) {
}
});
菜单视图
var MenuView = Backbone.View.extend({
el: $("#menu_container"),
events: {
},
template: Handlebars.compile(template),
initialize: function () {
console.log(this.model);<<<------------
this.render();
console.log("menuview");
},