Decorate a widget from inside an ajax success response


(Steven Slade) #1

Continuing the discussion from Are there any examples in Discourse of decorating a widget after an ajax request?:

Upon the success of an ajax call, I would like to decorate the post widget. The issue is that the api.decorateWidget does not immediately run after the ajax. My ajax call gets the post with the most likes, the decorator should add some elements via vDOM.

However, for this to work I have to scroll up and down the page twice for it work properly. The ajax run, sets an attribute to true and then I have go back to the top and have the widgetDecorator run and then scroll down and see the effect.

I tried putting the ajax inside the decorator and returning h('h1', 'test') but that didn’t work either.