mercredi 23 décembre 2015

How to update Ember model when data changes

In order to have a dropdown menu that reflects some data in my application, I'm querying the store in the application.js route:

import Ember from 'ember';

export default Ember.Route.extend({
  model() {
      var oldStuff  = this.store.query('stuff', {state: 0});
      var newStuff  = this.store.query('stuff', {state: 1});
      return {oldStuff: oldStuff, newStuff: newStuff};
  }
});

In this way I'm able to iterate on the model in application.hbs and my dropdown looks good, at first.

The problem is that it is static, and only changes if I refresh the page. I'm trying to think how to provide a model that changes when the data changes in the application.

I'm using Ember 1.13




Aucun commentaire:

Enregistrer un commentaire