I am creating some CRUD Ember.js 2.1.0 / Ember-data 2.1.0 with Ruby on Rails 5.
I have contacts and contacts/show route
When I click a item in list, current route Change to contacts/show route.
and contacts/show has isEdit variable for inline editing. but I expect isEdit will be reset when I click another item.
check my console when beforeModel, afterModel and setupController, all of my test spit false out. but it is not related with isEdit and template.
I click edit button isEdit is changed true
<p>
{{#if isEdit}}
<button {{action "save"}}>SAVE</button>
<button {{action "cancel"}}>CANCEL</button>
{{else}}
<button {{action "edit"}}>EDIT</button>
{{/if}}
</p>
my contacts/show template
save: function() {
var controller = this.controller;
var item = controller.get('model');
if(!item.get('title') || item.get('title') === '') {
item.rollbackAttributes();
controller.set('isEdit', false);
} else {
item.save();
controller.set('isEdit', false);
}
},
it works well, but I can't get 'false' on loaded new model
How I set isEdit false when I change same route and different model?
Aucun commentaire:
Enregistrer un commentaire