# Rerender on new route or transition

**URL:** <https://meta.discourse.org/t/rerender-on-new-route-or-transition/68253>\
**Category:** Development\
**Created:** [17 Agosto, 2017 16:54 UTC](https://meta.discourse.org/t/rerender-on-new-route-or-transition/68253 "2017-08-17T16:54:45Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [19 Agosto, 2017 14:02 UTC](https://meta.discourse.org/t/rerender-on-new-route-or-transition/68253/4 "2017-08-19T14:02:54Z")

</div>

Maybe you can try the following code (not tested):

```javascript
// My plugin initializer
export default {

	name: 'myPlugin',

	initialize(container) {

		// Reopen the router to add a didTransition hook
		const router = container.lookup('router:main')
		router.reopen({
			doSomething: function() {
				// Wait for rendering to be over. THIS DOESN'T WORK IN ALL CASES. 
				// In fact, there is no way to be sure rendering is complete, because 
				// a 'complete rendering' is meaningless (think about a looping DOM  
				// animation)
				Ember.run.schedule('afterRender', null, () => {
					// Do your stuff here
					...
				})
			}.on('didTransition')
		})

	}

}

```

---

_[View the full topic](https://meta.discourse.org/t/rerender-on-new-route-or-transition/68253)._
