samedi 6 juin 2015

How to get page to update with new records from server without a route change?

In my Ember app, I have a list of products that I display in my product route (which are fetched in the usual way upon entering the route)

   {{#each item in sortedProducts}}

   {{/each}}

....

App.ProductRoute = Ember.Route.extend({
      model: function(){
         return Ember.RSVP.hash({ 
            store: this.store.find('product'),
            formElements: ['Type','Price','Blah Blah']

         })
      }
})

In the controller, I do the sorting

sortProperties: ['date:desc'] //dated added
sortedProducts: Ember.computed.sort('model', 'sortProperties'),

This works, however, I give the user the option to filter the records displayed. Upon clicking a button, an action is called that queries the server for a subset of records
filterByPriceAndColor: function(){ this.store.find('product', {price: pricevariable, color: colorvariable}); }

This queries and returns the desired records, but the list on the page isn't updated i.e. the list on the page still displays all the records that are fetched upon application load.

Question: how do I get the page to update with the new records fetched from the server without a route change?




Aucun commentaire:

Enregistrer un commentaire