# Are there any examples in Discourse of decorating a widget after an ajax request?

**URL:** <https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175>\
**Category:** Development\
**Created:** [2016年五月12日 21:57 UTC](https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175 "2016-05-12T21:57:31Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)\
**Post date:** [2016年十一月26日 17:08 UTC](https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175/3 "2016-11-26T17:08:30Z")

</div>

The only solution I’ve found so far is to switch to Component and use bufferedRender and to observe for changes in local variable, then call re-render.

```
export default Ember.Component.extend(bufferedRender({

  @on("init")
  _updateContent() {
    if (!this.get('content')) {
      ajax("/growfaq.json").then(data => {
        this.set('content', data);
      });
    }
  }

  @observes('content')
  _rerenderOnChange() {
    this.rerenderBuffer();
  },

  
}));

```

Also

> [@eviltrout](#):
>
> Also I should note that widgets aren’t really meant to retrieve data. They can do it, but it usually makes a lot more sense to retrieve the data in a route or controller and pass it down to the widgets.

---

_[View the full topic](https://meta.discourse.org/t/are-there-any-examples-in-discourse-of-decorating-a-widget-after-an-ajax-request/44175)._
