I tried using instance.triggerEvent(eventName) within a button click function but it doesn’t want to trigger it. I’m probably doing something wrong but I don’t see much documentation on this other than Bubble saying that it is possible.
Bubble buttons all have a click handler that triggers events . If you want to trigger an event from a button you created in your plugin with html, you need to define an event in the plugin and then call it in the code.
What if the button is created outside of the plugin? I’m trying to check when a button is clicked using it’s ID Attribute and then activate a custom workflow. Is this possible?
I’m also not exactly sure what’s going on in your code as well. You’re triggering an event that you created above but what is it actually triggering?
sure. you need the id of the button
look for the button in your javacript
add an onclick handler
trigger an event
Think about triggerEvent like a way to tell the bubble app, “some action as occurred within my plugin so go ahead an run another workflow defined in the bubble app”
If you’re interested in booking a private session, I can help you build this functionality out in your own plugin!!
If I replaced the triggerEvent function with an alert, it shows up on click. So I know it can find the button and run through the function but it can’t see the custom event I’ve created.
I get an error saying event_clicked is not defined when it actually is…
My only problem now is that when combining this with a ‘beforeunload’ function, the prompt asking if I’d like to go or stay shows up first even though the line right before it should’ve made the offer popup visible. I’m doing this to give the user one last chance of getting a custom lower rate. I understand that the background will be blurred or partially visible but it’s better than checking the location of the mouse.
Would you happen to have any idea how I can possibly work around this? Perhaps making it an async function to make sure it loads prior to fully returning? Unfortunately, you can’t modify the unload text prompt but I’ve seen someone inject some css as a header in the background as an alert.