ember テキスト フィールド ビューを初期化して、クエリ文字列を事前入力しようとしています。しかし、ビューに init 関数を追加すると、他のすべての定義済みイベントのトリガーが停止します。
初期化の使用中にイベントを機能させ続けるにはどうすればよいですか?
App.SearchBarView = Ember.TextField.extend({
throttle_instance: _.debounce(function(){
var value = this.get('value');
this.update();
}, 1000),
/**
* Initialize the textbox with a set value
*/
init: function(){
var query = "testquery";
if(query && query.length > 0){
this.set('value', query[0]);
this.get('controller').set('query', query[0]);
this.update();
}
},
insertNewline: function() {
this.update();
},
/**
* Handle the keyup event and throttle the amount of requests
* (send after 1 second of not typing)
*/
keyUp: function(evt) {
this.get('controller').set('query', this.get('value'));
this.throttle_instance();
},
/**
* Update the pages results with the query
*/
update: function(){
var value = this.get('value');
this.get('controller').filterByQuery(value);
}
});