モデルのリストをフィルタリングできるカスタムフィールドがあります(一部のArrayControllerでは言うことができます)
PersonApp.SearchField = Ember.TextField.extend({
keyUp: function(e) {
var search = this.get('value');
model = PersonApp.Page.create({term: search});
this.get('controller.target').transitionTo('person.search', model);
}
});
これは、ページ付けとフィルタリング/検索の両方に使用している非常に単純なモデルです。
PersonApp.Page = Ember.Object.extend({
term: ''
});
上記のモデルで機能する簡単なルートを追加しました
PersonApp.Router.map(function(match) {
this.resource("person", { path: "/" }, function() {
this.route("page", { path: "/page/:page_id" });
this.route("search", { path: "/search/:page_term" });
});
});
そして最後に、これが私のルートsetupControllerメソッドです
PersonApp.PersonSearchRoute = Ember.Route.extend({
setupController: function(controller, model) {
this.controllerFor('person').set('filterBy', model.get('term'));
}
});
フィルタは機能します(つまり、上記のsetupControllerのfilterByを使用してArrayControllerを変更します)。
しかし、URLには次のように表示されます
http://www.google.com/#/search/<PersonApp.Page:ember517>
それ以外の
http://www.google.com/#/search/foo
代わりにテキストを表示するようにmodel/route / setupControllerを変更する方法はありますか?
また、このようなものは、上記のようなカスタムルートではなく、インデックス/メインルート上の単純な「イベント」である必要がありますか?もしそうなら、私はまだURLを変更できますか(私はそうではないと思います-それで私は今のところルートとしてそれを持っている理由です)