How refresh the ViewModel Data?

Is there any Refresh Method to refresh ViewModel Data ??

The easiest way is to leverage the model store by calling Portal.findAll({}) again. If you have setup the model correctly (‘id’ property), instances will be updated automatically through the store when the promise resolves. If the resulting list has a different number of results, however, I don’t believe can.Model handles this well, so can-connect has diffing logic for that case if you want to give it a try.

If you aren’t using can-connect and you need list diffing, here’s a semi-hacky trick where you create a dummy field as a dependency and then trigger it to cause a recompute.

define: {
  portals: {
    get: function(lastSetValue, resolve) {
      // recompute on 'refreshPortals' event
      this.attr('refreshPortals');
      Portals.findAll({}).then(resolve);
    }
  }
},
refreshData: function() {
  can.trigger(this, 'refreshPortals');
}

Hi,

thank you. refreshing now is working.

But why is my portals.isPending not working ?

That’s because portals is just a compute, not a promise. Instead, you could simply wait on portals in the template. Some people don’t like that style but it gets the job done.

Hi for anyone else, i tried a approach from Dylan from another Post and this works …