What is the right approach to reload the model for a non-dynamic route with ember.js?

前端 未结 1 845
余生分开走
余生分开走 2021-01-15 18:34

I\'m having a simple array of models which I display in a list (path: /things). The models get loaded from a REST-API.

In a nested route I have the functionality to

相关标签:
1条回答
  • 2021-01-15 19:19

    So if you were using ember-data, a side effect of saving the record would be that the results of findAll() get updated. You can accomplish the same by either manually updating the array or triggering a refresh when a new record is added. In either case, suggest doing that from ThingsAddController's add fx. For example:

    App.ThingsAddController = Em.ObjectController.extend({
      needs: [things],
      add : function() {
        newThing = App.Thing.save(this.content);
        this.get('controllers.things').pushObject(newThing);
        this.transitionToRoute('things');
      },
    });
    
    0 讨论(0)
提交回复
热议问题