【问题标题】:edit template not displaying on edit route编辑模板未显示在编辑路线上
【发布时间】:2013-12-18 00:49:07
【问题描述】:

我想编辑用户。我正在关注本教程:http://coding.smashingmagazine.com/2013/11/07/an-in-depth-introduction-to-ember-js/

我在user.hbs 中有一个按钮来编辑用户:

<button {{action "edit"}}>Edit</button> 及下面是{{outlet}}

当我点击它时,我被定向到/index.html#/users/4/edit,但我的user.edit.hbs 模板没有显示

这里是userEditRoute.js:

App.UserEditRoute = Ember.Route.extend({
  model: function(){ 
    return this.modelFor('user');
  }
});

还有userController.js:

App.UserController = Ember.ObjectController.extend({
  actions: {
    edit: function(){
      this.transitionToRoute('user.edit');
    }
});

为什么user.edit.hbs 不显示?

【问题讨论】:

  • 您是否在使用一些构建工具,例如:ember 应用套件、ember 工具等?

标签: javascript ember.js ember-data handlebars.js


【解决方案1】:

我不知道你是如何配置你的路由器的,但是一个带有 /users/<someid>/edit 的 URL 期望 this.transitionToRoute('user.edit', someObjectOrId);

【讨论】:

  • 我在userController.js 中有该代码(上面发布)。如果我将user 作为第二个参数传递,我会收到错误“用户未定义”并且它不指向/users/<someid>/edit
【解决方案2】:

我们可以通过以下方式做到这一点。 请检查此BIN

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-15
    • 2015-08-03
    相关资源
    最近更新 更多