问题
I would like to edit users. I am following this tutorial: http://coding.smashingmagazine.com/2013/11/07/an-in-depth-introduction-to-ember-js/
I have a button in user.hbs
to edit the user:
<button {{action "edit"}}>Edit</button>
and below it is an {{outlet}}
When click it I'm directed to /index.html#/users/4/edit
but my user.edit.hbs
template does not show up
Here's userEditRoute.js
:
App.UserEditRoute = Ember.Route.extend({
model: function(){
return this.modelFor('user');
}
});
And the userController.js
:
App.UserController = Ember.ObjectController.extend({
actions: {
edit: function(){
this.transitionToRoute('user.edit');
}
});
Why won't the user.edit.hbs
display?
回答1:
I don't know how you configured your router, but a url with /users/<someid>/edit
expect this.transitionToRoute('user.edit', someObjectOrId);
回答2:
We can do it in the following way. Kindly check this BIN
来源:https://stackoverflow.com/questions/20326145/edit-template-not-displaying-on-edit-route