K
K
kartio2015-05-20 15:04:51
Ember.js
kartio, 2015-05-20 15:04:51

Why is the template not updated after deleting a record?

Making the "load more" functionality for the list instead of pagination
Code for the 'loadMore' action:

this.store.findQuery('user', {
  skip: _this.get('skipped'),
  limit: _this.get('limit'),
  sort: _this.get('sort')
}).then(function(newData) {
  _this.get('model').pushObjects(newData.get('content'));
  _this.set('model.meta.total', newData.get('meta.total'));
  _this.set('skipped', _this.get('skipped') + _this.get('limit'));
});

code to delete
remove: function(item) {
  item.destroyRecord();
},

Sample
{{#each model as |row|}}
<tr>
   <a {{action 'remove' row}}>remove</a>
</tr>
{{/each}}
<a {{action 'loadMore'}}>loadMore</a>

When I delete elements loaded initially, the element is deleted both from the template and from the server.
When I click on "show more" and then try to delete new elements, they are deleted from the server, but the template is not updated. What am I doing wrong?..

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Romanov, 2015-05-20
@Kaer_Morchen

You can do this in the controller:
this.notifyPropertyChange('model');

D
Dmitry, 2015-05-29
@JuSay

Bind to a variable and that's it

E
Evgeny Lebedev, 2015-06-16
@HollowJ

in remove try to add
_this.get('model').removeObject(item);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question