我需要一些帮助。目前,如果我进入我的 Ember 应用程序到这样的网址
/#/clients/some-client/claims/123
页面加载正常。如果我手动将 url 更改为像这样简单的东西
/#/clients/some-client/claims/456
它不会更改数据。我实际上必须确保页面进行硬刷新以获取当前数据。
我在控制台中获得了事件跟踪,因为我在我的应用程序中设置了 LOG_TRANSITIONS
Transitioned into 'clients.client.claims.claim.index'
关于我可能出错的地方的任何想法?
路由器
Nucleus.Router.map(function () {
this.resource("clients", { path: 'clients' }, function () {
this.resource("client", { path: ':client_id' }, function () {
this.resource("claims", function () {
this.resource('claim', { path: '/:claim_id/:claim_sub' }, function () {
this.resource('lines', function () {
this.resource('line', { path: ':line_id' }, function () {
this.resource('flags', function () {
this.resource('flag', { path: ':flag_id' });
});
});
});
});
});
});
});
this.route("errors", { path: '/errors/:error_id' });
});
我的路线看起来像这样
Nucleus.ClientsRoute = Nucleus.Route.extend({
model: function (params) {
return Nucleus.Client.find('clients');
}
});
Nucleus.ClientRoute = Nucleus.Route.extend({
model: function (params) {
return Nucleus.Client.find('client', params);
}
});
Nucleus.ClaimsRoute = Nucleus.Route.extend({
model: function (params) {
var client = this.modelFor('client'),
clientId = client.get('data.id');
params.client_id = clientId;
return Nucleus.Claim.find('claims', params);
},
goToNextClaim: function (claim) {
this.transitionTo('claim', claim);
}
});
Nucleus.ClaimRoute = Nucleus.Route.extend({
model: function (params) {
var client = this.modelFor('client'),
clientId = client.get('data.id');
params.client_id = clientId;
return Nucleus.Claim.find('claim', params);
}
});
Nucleus.ApplicationRoute = Ember.Route.extend({
setupController: function () {
this.controllerFor('meta_property').set('model', Nucleus.MetaProperty.find('meta_property'));
this.controllerFor('header').set('model', Nucleus.User.find("user"));
}
});
控制器就是这样
Nucleus.ApplicationController = Nucleus.Controller.extend({
needs: ['meta_property'],
isErrorPage: false,
currentPathDidChange: function () {
if (this.get('currentPath') === 'errors') {
this.set('isErrorPage', true);
} else {
this.set('isErrorPage', false);
}
}.observes('currentPath')
});
Nucleus.ClaimController = Nucleus.ObjectController.extend({});
Nucleus.ClientController = Nucleus.ObjectController.extend({});