最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do you force Ember to rerender a component? - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 7

Without 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') 
发布评论

评论列表(0)

  1. 暂无评论