lundi 25 avril 2016

Ember.JS do an operation every time the JSON is loaded

I am new to Ember and in my APP I need to add some operations depending on the JSON I get from the server.

This is currently my logic:

In the component.js

var foo;

didInsertElement() {
 var data  = this.get('content');
 //then I do some transformations with data to obtain what I want and assign it to foo

  foo = someTransformationFromData;
}

So now the question is, I need to move this logic from didInsertElement to somewhere else so it gets executed every time I get my JSON no just the first time when the component is rendered. I have tried to use a serializer or a transform but I don't know if I can use any of them. Can you please give me any pointers about how to do this task?.

Thank you.




Aucun commentaire:

Enregistrer un commentaire