1
어쨌든 listenTo 메소드없이 다른 뷰에 백본 콜렉션을 보내어 배열이나 다른 것과 같이 보내도록 할 수 있습니까?컬렉션을 다른보기로 보내는 방법은 무엇입니까?
초기화 기능에서 가져 오기를 수행하고 컬렉션을 내 배열에 넣는 것은 나쁘지 않습니까?
this.userModels = [];
this.collectionUser = new app.types.Users();
this.collectionUser.fetch();
this.userModels.push(this.collectionUser);
배열처럼 보내려고 임하지만 때로는 내 웹 페이지를 새로 고침에서이
this.options child {
length: 15,
models: Array[15],
_byId: Object,
_listenId: "l4",
_events: Object…
}
를 받고 메신저 언젠가 0 값
this.options child {
length: 0,
models: Array[0],
_byId: Object,
_listenId: "l4",
_events: Object…
}
그래서 난 내를 보내 싶어
로 점점 가능한 경우 listenTo 메서드가없는 컬렉션.먼저보기 :
app.types.FirstView = Backbone.View.extend({
initialize: function() {
this.collectionUser = new app.types.Users();
this.collectionUser.fetch();
};
sendCollection: function() {
var secondView = new app.types.SecondView({
collection: this.collectionUser
});
}
});
두 번째보기 :
app.types.SecondView = Backbone.View.extend({
initialize: function(options) {
this.collection = options.collection;
// so i want to get this.collectionUser here without listenTo
// method and without fetch here is that possible ? I said
// sometimes i get it sometimes not when i refersh my web page
// when i render it first time.
};
});
나는 그것을했지만 다시보기 길이에 널 (null) '아이 점점 메신저 {길이 : 0, 모델 : 배열 [0], _byId : 개체}'. – lorenos
그럴 경우 콜렉션 인수와 뷰 콜렉션에 전달해야한다. colection.fetch() –
나는 지금 대답을 바꿀 것이다 –