I have an Ember ponent that uses jQuery to add a canvas chart. When I change routes, I get a new model, but Ember's automatic rerendering does not work in this case. In fact, I don't know how to make the ponent code which adds the chart re-run at all. How can I do this?
Would it work better if it was a view?
I have an Ember ponent that uses jQuery to add a canvas chart. When I change routes, I get a new model, but Ember's automatic rerendering does not work in this case. In fact, I don't know how to make the ponent code which adds the chart re-run at all. How can I do this?
Would it work better if it was a view?
Share Improve this question asked Jun 12, 2015 at 17:26 JoeJoe 8,04218 gold badges57 silver badges86 bronze badges 2-
1
What code are you using to render the chart in the first place? Is it on
init
? It sounds like you need to observe the model as well, and when the model changes run that code again. Views are being deprecated, ponent is the way to go. – Kingpin2k Commented Jun 12, 2015 at 17:29 - I have it run on InsertElement. – Joe Commented Jun 12, 2015 at 17:49
1 Answer
Reset to default 7Without looking at code, I'm going to guess based on your statement of the model changing.
Component Currently
uiSetup: function(){
// do magic here...
}.on('didInsertElement')
Component with observes
Assuming the model in the ponent is named model, this would fire every time the model changed as well as when the element was initially inserted into the page. You could also break it into two separate functions if you need it to act differently on model change vs element inserted first time.
uiSetup: function(){
// do magic here...
}.on('didInsertElement').observes('model')