이 백본 스크립트에는 단일 뷰와 컨트롤러로 작동하는 모델이 있으며 서버에서 데이터를 가져 오는 콜렉션 url: '/search/:term'
이 있습니다.변경 모델 이벤트 콜렉션을 재설정 하시겠습니까?
var Items = Backbone.Collection.extend({
initialize: function(terms){
this.fetch();
}
url: 'search/:term'
});
var Controller = Backbone.Model.extend({
defaults:{
term: ""
},
initialize: function(opts){
this.on('change:term', function(term){
console.log(this.get("term"));
// every time term changes i want to refresh the collection with the new data
// so it will fetch data from url:'search/ + term'
});
누군가 고맙습니다. } });
성취하려는 것을 발견 할 수 있습니까? 어떤 dom-event를 듣고 자한다면, Backbone.View를 사용해야합니다. 백본 컨텍스트에서보기는 컨트롤러로 작동합니다. –