컬렉션에 뷰 바인딩을 정의했습니다.컬렉션을 가져올 때 렌더 함수가 호출되지 않음
1)보기를 초기화 할 때 콜렉션에서 가져 오기 호출이 수행됩니다.
2) get 요청 결과를 보면 괜찮습니다.
3) 렌더링 기능을 호출하기 위해 myCollection에서이 변경을 트리거하고 싶지만 작동하지 않습니다. 여기
내 코드의 일부입니다 : 내가 사용하는 경우
define([
"MyCollection",
"!text/template"
], function (myCollection, myTemplate) {
var myView = Backbone.View.extend({
initialize: function()
{
myCollection.bind('change', this.render); // why the render is not called when
// I perform the fetch even if the data is correctly loaded?
myCollection.fetch(); // it works
},
render: function()
{
// some code
this.$el <-- undefined
}
});
return myView;
});
1)
initialize: function()
{
myCollection.bind('reset', this.render); // this.$el <-- undefined in render call, Why?
myCollection.fetch(); // it works
}
2)
myCollection.fetch({
success: function() {
that.render(); // <-- here the $el is defined and it works, Why myCollection.bind('reset', this.render); not??
// it seems to me that when I use reset the render function is called before the this.$el is defined
}
});
의 성공적인 완료에 변경 이벤트 트리거 나는 다음과 같은 메시지가 얻을 :'catch되지 않은 형식 오류를 : 정의되지 않은 메소드 'html'을 호출 할 수 없습니다. 내 질문에 대한 자세한 내용 – underscore666