samedi 18 mars 2017

How to rerender a component when it contains a helper?

The problem

I'm trying to rerender a component after an action, but the part of the template i need to rerender is not updated, because it comes from the result of a helper i made, or at least i think it's because of that.

In my component template, i have something like this :



In the component js file associated, i have this action :

fillGrid(location, length) {
  /* logic */

  this.rerender();
},

How i did

I found a way to do it but it felt weird, i'm using a booelan that i toggle between true and false in the action to force rerender

fillGrid(location, length) {
    let me = this;
    this.set('show', false);

    /* logic */

    Ember.run.later(function() {
      me.set('show', true);
      me.rerender();
    }, 10);
}

And in the template :


    


Is it the right way to do it ?




Aucun commentaire:

Enregistrer un commentaire