# Trigger a custom event from a reusable element

**URL:** <https://forum.bubble.io/t/trigger-a-custom-event-from-a-reusable-element/42224>\
**Category:** Need help\
**Created:** [November 13, 2018, 4:56am UTC](https://forum.bubble.io/t/trigger-a-custom-event-from-a-reusable-element/42224 "2018-11-13T04:56:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![philabong](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@philabong](https://forum.bubble.io/u/philabong)\
**Post date:** [November 13, 2018, 4:56am UTC](https://forum.bubble.io/t/trigger-a-custom-event-from-a-reusable-element/42224/1 "2018-11-13T04:56:22Z")

</div>

Hello Everyone - As far as I know, it looks like the easiest way for different reuseable elements to reference or to act on each other is by using the “Trigger a custom event from a reusable element” action.

However, for example, when I select this function in the ReuseableElement A’s workflow, it doesn’t show the custom event that’s created within ReuseableElement B’s workflow.

![Capture2](https://us1.discourse-cdn.com/bubble/original/3X/6/1/615e7af7e59807cde09ec4868c0b4a46b79eab6b.png)

Is this is a bug or am I approaching this the wrong way?

Thank you everyone.

---

<div class="post-metadata">

**Author:** ![daniel.alberttis](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@daniel.alberttis](https://forum.bubble.io/u/daniel.alberttis)\
**Post date:** [November 13, 2018, 11:30pm UTC](https://forum.bubble.io/t/trigger-a-custom-event-from-a-reusable-element/42224/2 "2018-11-13T23:30:05Z")

</div>

Try using the [Env variable plugin](https://www.notion.so/Bubble-Developer-Kit-3eb057d9d81d4176b1be678856c80faf#be6bbde5ee444a13ade861561338a594)

---

<div class="post-metadata">

**Author:** ![mishav](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mishav/32/6420_2.png) [@mishav](https://forum.bubble.io/u/mishav)\
**Post date:** [November 14, 2018, 6:22am UTC](https://forum.bubble.io/t/trigger-a-custom-event-from-a-reusable-element/42224/3 "2018-11-14T06:22:45Z")

</div>

It seems a custom event can only be triggered from the same page workflow as it is defined.

Here’s one way to get around it … altering the reusable’s custom state.

Reusable A workflow (example triggered by a button)  
Reusable B has the custom event workflow  
Reusable C includes Reusable A and Reusable B, it could be a page instead of another reusable.

- Reusable A’s workflow:
  - set A’s custom state to current datetime extract milliseconds

- Reusable B workflow “do when B’s custom state is not B’s other custom state”:
  - set B’s other custom state to B’s custom state
  - trigger B’s custom event

- Page or Reusable C workflow “do when A’s custom state is not B’s custom state”:
  - set B’s custom state to A’s custom state

The “do when” can be set to “once only” if you only want one occurrence, or “every time”.

Another way to get around it is to set a javascript variable, as @daniel.alberttis hinted at. Any of the javascript plugins can do this.

---

<div class="post-metadata">

**Author:** ![gaurav](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gaurav/32/6666_2.png) [@gaurav](https://forum.bubble.io/u/gaurav)\
**Post date:** [November 14, 2018, 8:19am UTC](https://forum.bubble.io/t/trigger-a-custom-event-from-a-reusable-element/42224/4 "2018-11-14T08:19:54Z")

</div>

Check out the second demo:  
[https://bdkdemos.bubbleapps.io/env\_variable](https://bdkdemos.bubbleapps.io/env_variable)

Can’t think of an easier way to do this 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [January 22, 2019, 5:07am UTC](https://forum.bubble.io/t/trigger-a-custom-event-from-a-reusable-element/42224/5 "2019-01-22T05:07:16Z")

</div>

Closed on January 22, 2019, 5:07am UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
