このバックボーンスクリプトには、単一のビューとコントローラーとして機能するモデル、およびサーバーからデータがフェッチされるコレクションがあります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'
});
誰かがこれで私を助けてくれますか?}});