# Execute script after dashboard loads

**URL:** <https://discuss.elastic.co/t/execute-script-after-dashboard-loads/114801>\
**Category:** Kibana\
**Created:** [January 10, 2018, 6:58am UTC](https://discuss.elastic.co/t/execute-script-after-dashboard-loads/114801 "2018-01-10T06:58:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karan\_Sharma](https://avatars.discourse-cdn.com/v4/letter/k/b5ac83/32.png) [@Karan\_Sharma](https://discuss.elastic.co/u/Karan_Sharma)\
**Post date:** [January 10, 2018, 6:58am UTC](https://discuss.elastic.co/t/execute-script-after-dashboard-loads/114801/1 "2018-01-10T06:58:32Z")

</div>

I have some code in hack.js which needs to be executed ONLY AFTER the dashboard had loaded, is there any event emitted when a dashboard finishes loading?

Some more detail:  
I need to access dashboard name using $route.current.locals, hack.js executes before dashboad load and $route.current.locals is a null value, any way to avoid this?

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [January 10, 2018, 2:25pm UTC](https://discuss.elastic.co/t/execute-script-after-dashboard-loads/114801/2 "2018-01-10T14:25:28Z")

</div>

Hey @Karan_Sharma we aren't emitting any events when the Dashboard saved object loads and is added to the $route.current/locals. What is it that you're trying to accomplish in your `hack.js`? Perhaps there is another way to accomplish your objective.

You could potentially poll periodically until that value that you need is there, but that's rather "hackish".

---

<div class="post-metadata">

**Author:** ![Karan\_Sharma](https://avatars.discourse-cdn.com/v4/letter/k/b5ac83/32.png) [@Karan\_Sharma](https://discuss.elastic.co/u/Karan_Sharma)\
**Post date:** [January 11, 2018, 10:09am UTC](https://discuss.elastic.co/t/execute-script-after-dashboard-loads/114801/3 "2018-01-11T10:09:20Z")

</div>

Thanks, i actually ended up using $scope.$watch. It worked 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 8, 2018, 10:09am UTC](https://discuss.elastic.co/t/execute-script-after-dashboard-loads/114801/4 "2018-02-08T10:09:47Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
