Reprogram Content

I am trying to reload the model and reframe locationContent. The model appears to be reloading, but assemblyContent is not being revised. Data sorting is great, it adds and removes data that is causing the problem.

reloadModelData: function () {
  this.get('target.router').refresh();
}

      

My template looks like this:

{{#each project in arrangedContent}}
<tr>
  <td>{{project.name}}</td>
  ...
</tr>
{{/each}}

      

Edit:

routes / projects / index.js

import Ember from 'ember';

export default Ember.Route.extend({
  model: function () {
    return this.store.findAll('project');
  }

});

      

Controllers / projects / index.js

import Ember from 'ember';

export default Ember.Controller.extend(Ember.SortableMixin, { 
  queryParams: ['sortProperties', 'sortAscending'],
  sortProperties: ['name'],

  actions: {
    ...

    reloadModelData: function () {
      this.get('target.router').refresh();
    }
  }
});

      

The button is what gets triggered reloadModelData

<button {{action 'reloadModelData'}}>Reload</button>

      

+3


source to share


1 answer


Your trick model

fails in your action. What for? You are executing #refresh()

on targer.router

which is not current as well Router

.

So how can you update the model?

There is a convention called data-down-action-up. It supports dispatching actions up to objects that are, say, parents, to modify data. A possible solution would be to make your bubble reloadModelData

up the route and handle that action in route

. Then in this action you can get the data again and set it on the controller:

# controller code    
reloadModelData: function() {
  return true;
}

      



And on the way:

# route code
reloadModelData: function() {
  this.store.find('project').then((function(_this) {
    return function(projects) {
      _this.get('controller').set('model', projects);
    };
  })(this));
}

      

If the result from find

is different from what it was, the associated calculations model

will most likely be recalculated.

Here's a working demo in JSBin that compares his and mine for a solution.

+1


source







All Articles