# When Do Plugin Hacks Trigger

**URL:** <https://discuss.elastic.co/t/when-do-plugin-hacks-trigger/237010>\
**Category:** Kibana\
**Created:** [June 14, 2020, 2:36am UTC](https://discuss.elastic.co/t/when-do-plugin-hacks-trigger/237010 "2020-06-14T02:36:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [June 14, 2020, 2:36am UTC](https://discuss.elastic.co/t/when-do-plugin-hacks-trigger/237010/1 "2020-06-14T02:36:38Z")

</div>

When on a dashboard my hacks will trigger the first time. If I click the breadcrumbs to go back to dashboard and click on other dashboards hacks.js will not trigger again until I click another app and the page reloads.

Is that by design? It kind of kills my plugin I am working on if hacks don't trigger on every single page that is clicked on.

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [June 14, 2020, 8:19am UTC](https://discuss.elastic.co/t/when-do-plugin-hacks-trigger/237010/2 "2020-06-14T08:19:10Z")

</div>

hacks.js is triggered once when Kibana loads on the initial page load. When navigating between dashboards, Kibana is handling this navigation internally without reloading the whole page, so hacks are not triggered again.

In your hacks file you could listen for the hash change event and trigger your logic based on that.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [June 14, 2020, 12:34pm UTC](https://discuss.elastic.co/t/when-do-plugin-hacks-trigger/237010/3 "2020-06-14T12:34:08Z")

</div>

Thanks. I will give that a shot.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [June 14, 2020, 1:20pm UTC](https://discuss.elastic.co/t/when-do-plugin-hacks-trigger/237010/4 "2020-06-14T13:20:38Z")

</div>

Here's what I came up with if anyone else needs it.

```auto
import $ from "jquery";

window.onhashchange = locationHashChanged;

$(document).ready(function () {
  console.log("On Ready");
  initHack();
});

function locationHashChanged() {
  console.log("On Change");
  initHack();
}

```

---

<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:** [July 12, 2020, 1:20pm UTC](https://discuss.elastic.co/t/when-do-plugin-hacks-trigger/237010/5 "2020-07-12T13:20:41Z")

</div>

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