我有以下設置:灰燼數據重寫URL
App.Router.map(function() {
this.route('tab', { 'path' : 'tab/:which' });
});
App.ApplicationStore = DS.Store.extend({});
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: '../api'
});
App.TabAdapter = DS.RESTAdapter.extend({
find: function(store, type, id) {
alert("I doesn't get invoked");
return this._super(store, type, id);
}
});
App.TabRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('emails', {tab: "inbox"});
}
});
,參觀路線#/tab/inbox
當我想從 http://localhost/ba/api/emails?tab=inbox
改寫爲端點URL到 http://localhost/ba/api/emails/inbox
。因此,我重寫了find()
-方法TabAdapter,但this.store.find('emails', {tab: "inbox"});
運行時,它不會進入我的重寫方法(並且我的測試警報不會被調用)。
爲什麼我的被覆蓋的find()
-method沒有被調用?
我是新來的灰燼,但有一個TabsController和Tab模型類呢? – GSP 2014-11-04 13:27:00
是的,但它們目前是空的,如果未指定,Ember會自動爲路線創建控制器。 App.TabController = Ember.Controller.extend({}); App.Tab = DS.Model.extend({}); – 2014-11-04 13:31:58