mardi 12 janvier 2016

Ember: Update UI based on model value change

I have a model that is updated based on an async call. For some reason, the UI does not get updated. Could you point me to why this might be happening. The code is below. I have verified that the code does work if I do not have an async call. I am using ember 2.0. Thank you for your help.

App.GroupsRoute = Em.Route.extend({
  model: function() {
        var groupsData = [];
         Promise.resolve(Ember.$.ajax({
              type: 'POST',
              url: '/someservice.json',
              contentType: 'application/json',
              data: JSON.stringify({
                allFor: 'group',
                query: ''
              })
            })).then(function(data) {
                groupsData = data.items;
                return groupsData;
            }.bind(this)).catch(function(error) {
              console.log('Error retrieving devices data ' + error);
            });
        return groupsData;    
  }
});




Aucun commentaire:

Enregistrer un commentaire