當模型爲isNew
時,如何在deactivate
路由掛鉤中執行get('transaction').rollback()
或deleteRecord()
模型的路由掛鉤?我無法弄清楚如何從鉤子中訪問模型。從路由中的停用掛鉤觸發model.get('transaction')。rollback()
app.js
App.Router.map(function() {
this.resource('users', function() {
this.route('new');
})
});
App.UsersNewRoute = Ember.Route.extend({
model: function() {
return App.User.createRecord();
},
activate: function() {
this.controllerFor('users').set('newUserCreate', true);
},
deactivate: function() {
this.controllerFor('users').set('newUserCreate', false);
}
});
不知道,但也許你可以使用this.currentModel https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/ lib/system/route.js#L254 – 2013-05-07 20:55:13