Ember.js 余烬已移除,但仍在燃烧
这件事让我困惑不解。我对ember还是新手,但我有一些嵌套的路由,我在父路由上使用重定向钩子调用Ember.js 余烬已移除,但仍在燃烧,ember.js,nested-routes,Ember.js,Nested Routes,这件事让我困惑不解。我对ember还是新手,但我有一些嵌套的路由,我在父路由上使用重定向钩子调用transitiono,以拉入嵌套的子路由 App.CategoryRoute = Ember.Route.extend({ redirect: { transitionTo('subcategories'); } }); 我删除了重定向钩子和转换到,但是转换仍在进行。我甚至关闭了我的项目并重新打开,清除了所有浏览器上的缓存,但它仍然保持着过渡状态。我也试着在重定向下调用一个虚假的路由,结果它
transitiono
,以拉入嵌套的子路由
App.CategoryRoute = Ember.Route.extend({
redirect: { transitionTo('subcategories'); }
});
我删除了重定向钩子和转换到
,但是转换仍在进行。我甚至关闭了我的项目并重新打开,清除了所有浏览器上的缓存,但它仍然保持着过渡状态。我也试着在重定向下调用一个虚假的路由,结果它出错了。一旦我移除,它就会返回到这个行为,并转换到子路由。有人有过这样的经历吗?我做错了什么?如果您需要更多代码,请告诉我
下面是代码的其余部分。在我的故障排除中,我删除并添加了很多东西,我将尝试让它恢复到开始发生时的状态。我还从Handlbar代码部分删除了尽可能多的“绒毛”,以使其更清晰
App = Ember.Application.create({
rootElement: "#app",
LOG_TRANSITIONS: true
});
App.Router.map(function () {
this.resource("category", function () {
this.resource('subcategories', { path: "/" }, function () {
//subcategory route show list of items in that subcategory
this.resource('subcategory', { path: "/:subcategoryslug" }, function () {
//this is individual item
this.route("item", { path: "/:itemid" });
});
});
});
});
App.CategoryRoute = Ember.Route.extend({
redirect: { transitionTo('subcategories'); }
});
App.CategorySubcategoriesRoute = Ember.Route.extend({
model: function (params) {
Ember.Logger.warn("Inside category route");
categoryid = 47
//this calls extended object for json data
//works just fine when routes are rendered.
return App.Subcategory.findAll(categoryid);
}
});
这是把手座:
<script type="text/x-handlebars" data-template-name="index">
<h2>APPLICATION TITLE</h2>
<div>
<strong>{{#link-to 'category'}}CategoryName{{/link-to}}</strong>
</div>
</script>
<script type="text/x-handlebars" data-template-name="category/index">
<h2>Category Name</h2>
<div>
{{outlet "subcategories"}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="category/subcategories">
{{#each subcategory in model}}
<div>
<strong>{{#link-to 'category.subcategory.index' subcategory}}{{subcategory.subcategoryname}}{{/link-to}}</strong><br>
{{subcategory.description}}
</div>
{{/each}}
</script>
申请名称
{{{#链接到“类别”}类别名称{{/link to}}
类别名称
{{出口“子类别”}
{{{#模型中的每个子类别}
{{{#链接到'category.subcategory.index'subcategory}{{subcategory.subcategory name}{{/link to}}
{{subcategory.description}}
{{/每个}}
你能展示一下你剩下的代码吗?哦,天哪。我得到了它。我的路线图就是问题所在。将子类别路径指定为与类别路由相同显然会导致问题。我试图让它们在另一条路径内部渲染,但这有点多余。所以这是固定的。很抱歉