Backbone.js의 Todo.js 튜토리얼에서 "this"가 무엇을 의미하는지 이해하는 데 어려움을 겪고 있습니다. 특정에서는 앱 조회 내부 :Todo.js에서 언급 한 키워드는 무엇입니까? (백본 튜토리얼)
initialize: function() {
this.input = this.$("#new-todo");
this.allCheckbox = this.$("#toggle-all")[0];
Todos.bind('add', this.addOne, this);
Todos.bind('reset', this.addAll, this);
Todos.bind('all', this.render, this);
this.footer = this.$('footer');
this.main = $('#main');
},
그래서 Todos.bind가 ('추가', this.addOne이)가 컬렉션에보기 (this.addOne)를 결합한다 ('추가'라고). 그렇다면 세 번째 매개 변수 ("this")도 AppView 개체를 참조한다고 가정합니다. 왜 "this"를 세 번째 매개 변수로 사용해야합니까?
주석 소스 코드 : http://backbonejs.org/docs/todos.html
해명 해 주셔서 감사합니다. 매우 감사. 한 가지 더 궁금한 점이 있습니다. 소스 코드에서 AppView의 addOne 함수에 대해 매개 변수 "todo"가 참조하는 것은 무엇입니까? – Sean
@SeanDokko 인스턴스화 된'TodoList' 컬렉션에 대한 참조입니다. – alex
TodoList는 모델이 아니라 컬렉션이 아니기 때문에 충돌이 없습니까? 모델 : 새로운 모델보다는 모델 : 할일? – Sean