【问题标题】:Resource with nested resource not loading on back button when using render使用渲染时,具有嵌套资源的资源未在后退按钮上加载
【发布时间】:2023-03-27 19:18:01
【问题描述】:

我的 emberjs 代码在以下 jsbin 中,

http://emberjs.jsbin.com/rewumojixe

我正在尝试将“搜索”资源嵌套在我的“汽车”资源中,因为我希望路线为汽车/搜索。我已经使用 renderTemplate 在应用程序出口中加载搜索资源来替换渲染的汽车模板。

App.SearchRoute = Ember.Route.extend({
    renderTemplate: function () {
        this.render('search', { into: 'application' });
    }
});

这工作正常,除了在搜索路线上单击返回按钮时加载的是空的汽车路线。这仅在将上述 renderTemplate 代码添加到 SearchRoute 时才会发生。

【问题讨论】:

    标签: ember.js


    【解决方案1】:

    如果您不想嵌套路由,请不要嵌套它们。

    App.Router.map(function() {
        this.resource('home',   { path: '/' });
        this.resource('cars',   { path: '/cars' });
        this.resource('search', { path: '/cars/search' });
    });
    

    演示:

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 2014-12-05
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多