I have following function:
this.store.createRecord('user', params).save().then(()=>{
this.set('responseModal', 'Utworzono użytkownika!');
})
And my question is: Why Ember push record to store before response from server? For example: I'm filling form incorrectly, and my server return with error and status: 400, but my record without it's id-key is still in store. I tried something like this:
.catch(()=>{
user.unloadRecord();
});
But it looks bad, when something record display and instantly hide. Is something way to create record in store only after response from server without external libraries? I want to use only ember-data to connect client with the server. Any advice and suggestions will be appreciated
If the form submission is not succeeded then we will give them another attempt with already user provided data. so we need to store the data in store
. if you are navigating to some other page or don't want to give another attempt with old data then you can always use rollbackAttributes
If the model hasDirtyAttributes this function will discard any unsaved changes. If the model isNew it will be removed from the store.