# Plugin: performing DOM manipulation on pages

**URL:** https://meta.discourse.org/t/plugin-performing-dom-manipulation-on-pages/65936
**Category:** Development
**Created:** [July 10, 2017, 1:12pm UTC](https://meta.discourse.org/t/plugin-performing-dom-manipulation-on-pages/65936 "2017-07-10T13:12:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [July 10, 2017, 1:12pm UTC](https://meta.discourse.org/t/plugin-performing-dom-manipulation-on-pages/65936/1 "2017-07-10T13:12:58Z")

</div>

I would like to run jQuery operations on Disourse topic pages from my plugin, but I cannot find a hook that fires after a topic page is displayed.

I’ve tried `route:didTransition`, `route:setupController`, `component:didInsertElement`, adding nested `Ember.run.schedule('afterRender')` and `Ember.run.next()`, but they all fire before the display occurs.

(to be more precise, they fire _after_ display when refreshing the browser, but _before_ display when changing route thereafter).

I could go with `setTimeout(1000)`, but I’m sure there’s a clean way… Anybody on this?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [July 10, 2017, 4:07pm UTC](https://meta.discourse.org/t/plugin-performing-dom-manipulation-on-pages/65936/2 "2017-07-10T16:07:52Z")

</div>

It’s a little tricky depending on what you are trying to do. For example, scrolling a topic will change its DOM, as will interacting with it via various buttons.

If you only want to apply some jQuery to a topic after it’s been rendered and that will work for you, you could try reopening the `discourse-topic` component and adding a [lifecycle callback](https://guides.emberjs.com/v2.6.0/components/the-component-lifecycle/) – `willRender` should work.

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [July 10, 2017, 4:27pm UTC](https://meta.discourse.org/t/plugin-performing-dom-manipulation-on-pages/65936/3 "2017-07-10T16:27:48Z")

</div>

Thanks a million, `willRender` and `didRender` seem to work!
