dimanche 5 juin 2016

Ember.js - Add record to store when using store.query?

How should I update my model to include new records when using store.query? I'm using store.query for pagination. From what I've read, I can push the record into the store, but can't seem to get this working?

    // users/route.js
    ...
    model(params) {
        return this.store.query('user', {
            page: {
                number: params.page,
                size: params.size
            }
        });
    },
    ...

    // users/new/route.js
    ...
    model() {
        return this.store.createRecord('user');
    },

    actions: {

        save() {
            let model = this.controllerFor('users').get('model');
            model.save().then(() => {
                console.log('user saved');
                this.transitionTo('users');
            });
        },
    ...




Aucun commentaire:

Enregistrer un commentaire