vendredi 2 décembre 2016

How to prevent EmberJS list from displaying deleted records?

I am having problems getting my EmberJS/Ember-Data project to NOT display deleted records.

I have a route: users/route.js

export default Ember.Route.extend({
    model: function() {
        console.debug('UserRoute.model');
        return this.store.findAll('user');
    }
});

the template: users/template.hbs

<table class="table table-condensed table-hover" style="table-layout:fixed">
        
            <tr  class=>
                <td></td>
            </tr>
        
    </tbody>
</table>

The user route: user/route.js

export default Ember.Route.extend({
    actions: {
        deleteUser: function(user) {
            var record = this.modelFor('user');
            record.destroyRecord().then(() => {
                this.transitionTo('users');
            });
        },
    }
});

user template generates the deleteUser action.

Using Ember Inspector on the user model data with id 59

Using Ember Inspector on the user model data with id 59

After calling destroyRecord:

the network transaction headers

the network transaction headers

and response payload from backend

and response payload from backend

Now the user record flags in the store

Now the user record flags in the store

But the item continues to be displayed in the users route, allowing one to view and subsequently try to delete again only to receive the error:

error

What am I doing wrong!

Thanks, Barry




Aucun commentaire:

Enregistrer un commentaire