admin管理员组文章数量:1415698
My route is defined:
this.resource("visitor", {path: ":id"});
When I visit the page via the URL /12345
, the value of this.currentModel
is
{id: "12345"}
but when I this.transitionToRoute("visitor", "12345")
from another (parent) controller, the value of this.currentModel
is
"12345"
I also get this exception:
Uncaught Error: assertion failed: Path '12345' must be global if no obj is given.
Any ideas what's going on?
More code:
App.VisitorRoute = Ember.Route.extend({
model: function (params) {
return {id: params.id};
},
setupController: function() { ... }
}
My route is defined:
this.resource("visitor", {path: ":id"});
When I visit the page via the URL /12345
, the value of this.currentModel
is
{id: "12345"}
but when I this.transitionToRoute("visitor", "12345")
from another (parent) controller, the value of this.currentModel
is
"12345"
I also get this exception:
Uncaught Error: assertion failed: Path '12345' must be global if no obj is given.
Any ideas what's going on?
More code:
App.VisitorRoute = Ember.Route.extend({
model: function (params) {
return {id: params.id};
},
setupController: function() { ... }
}
Share
Improve this question
asked May 29, 2013 at 10:31
SriSri
5,84510 gold badges51 silver badges68 bronze badges
2 Answers
Reset to default 3You need to explain to the router how to translate your model into a URL, for that you need to override serialize
.
App.VisitorRoute = Ember.Route.extend({
model: function (params) {
return {id: params.id};
},
serialize: function(model) {
return model;
}
});
After that pass the model with the transition:
this.transitionToRoute('visitor' , { id: 12345 });
When you call this.transitionToRoute() you need to pass in the route and the model as arguments, so instead of this.transitionToRoute("visitor", "12345"), rather use this.transitionToRoute("visitor", vistorModel)
本文标签: javascriptEmber transitionToRoute and currentModel issueStack Overflow
版权声明:本文标题:javascript - Ember .transitionToRoute and currentModel issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745238262a2649165.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论