ember.js:向子路由的转换将重新加载父路由';s模板
我发现,当我转换到不同的子路由时,与父路由关联的模板也会刷新。我希望避免父模板“闪烁”,因为它不需要更新 具体来说,我有一个路由器,具有两个嵌套级别:ember.js:向子路由的转换将重新加载父路由';s模板,ember.js,Ember.js,我发现,当我转换到不同的子路由时,与父路由关联的模板也会刷新。我希望避免父模板“闪烁”,因为它不需要更新 具体来说,我有一个路由器,具有两个嵌套级别: App.Router.map(function() { this.resource("first", {path: "/first/:first_id"}, function(){ this.resource("second", {path: "/second/:second_id"}, function(){ this.
App.Router.map(function() {
this.resource("first", {path: "/first/:first_id"}, function(){
this.resource("second", {path: "/second/:second_id"}, function(){
this.route("routeone");
});
});
和相应的模板:
<script type="text/x-handlebars" data-template-name="second">
Some stuff
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="second/routeone">
Some more stuff
</script>
“routeone”路由从URL获取JSON:
App.SecondRouteoneRoute = Ember.Route.extend({
model: function(params){
var first_id = this.modelFor('first').id;
var second_id = this.modelFor('second').id;
var dataurl = "/_data/" + first_id + "/" + second_id;
return Ember.$.getJSON(dataurl);
},
当我从/first/X/second/Y/routeone转换到/first/X/second/Z/routeone时,“second”模板中的“Some stuff”文本会闪烁。这可以避免吗?你能给我们提供路由实现吗?给内部资源作为路由…他们尝试了。添加了路由实现。
App.SecondRouteoneRoute = Ember.Route.extend({
model: function(params){
var first_id = this.modelFor('first').id;
var second_id = this.modelFor('second').id;
var dataurl = "/_data/" + first_id + "/" + second_id;
return Ember.$.getJSON(dataurl);
},