【发布时间】:2014-11-27 17:28:10
【问题描述】:
我需要在我的带有主干的 html 模板中花费 1 个模型和 1 个集合。但有时,html 在模型之后就准备好了。 我有:
var FormUtilisateurView = Backbone.View.extend({
initialize: function(id){
this.listeClient = new ClientsCollection();
this.utilisateur = new UtilisateurModel({ id : id });
},
render: function(){
var that = this;
this.utilisateur.fetch();
this.listeClient.fetch().done(function(){
that.$el.html(FormTemplate({ clients : that.listeClient.models, user : that.utilisateur }));
});
return this;
}
});
这里只加载 listeClient 集合。 我想确保我的模型和集合在模板之前加载。
提前谢谢你
【问题讨论】:
标签: jquery backbone.js collections model fetch