私のバックボーン アプリでは、3 つのコレクションを読み込み、レンダリング機能で「リセット」イベントをバインドします。したがって、このように、コレクションを取得すると、さまざまな結果が出力されますが、同時にではありません。
jquery 遅延メソッド ($.when、$.then) を使用してすべてを同時に出力しますが、ビューで「バインド イベント」を使用する場合はどうすればよいですか?
これはコードです:
ルーター:
App.Routers.test1 = Backbone.Router.extend({
routes: {
"/test" : "test"
},
initialize: function() {
// Models
this.Models_1 = new App.Collections.coll_1;
this.Models_2 = new App.Collections.coll_2;
this.Models_3 = new App.Collections.coll_3;
// Views
this.View_1 = new App.Views.view_1( {model: this.Models_1} );
this.View_2 = new App.Views.view_2( {model: this.Models_2} );
this.View_3 = new App.Views.view_3( {model: this.Models_3} );
},
test: function() {
$.when(
this.Models_1.fetch(),
this.Models_2.fetch(),
this.Models_3.fetch()
).then(function() {
// ?????????????????????????
// What should I do here?
// ?????????????????????????
});
}
});
ビュー 1:
App.Views.view_1 = Backbone.View.extend({
initialize: function() {
_.bindAll(this, 'render');
this.model.bind('reset', this.render);
},
render: function() {
// print the data...
}
});