mercredi 30 novembre 2016

Emberjs create new model after saving

This seems extremely trivial and I feel awkward asking but I can't seem to create a fresh model after saving the current.

Think todo app, where you want to keep adding new tasks:

I have a very simple route which saves correctly, but doesn't update the frontend with a new model

  model() {
    return RSVP.hash({
      distro: get(this, 'store').createRecord('distro'),
    });
  },

  setupController(controller, models) {
    controller.setProperties(models);
  },

  actions: {
    saveDistro(distro) {
      let newDistro = get(this, 'store').createRecord('distro');

      distro.save().then(() => {
        set(this, 'distro', newDistro);
      });
    },
  }

I think I'm just missing the obvious here?




Aucun commentaire:

Enregistrer un commentaire