No way to turn off 'webWidget:on' events handlers | Community
Skip to main content

No way to turn off 'webWidget:on' events handlers

  • November 23, 2021
  • 4 replies
  • 0 views

Stefania11

I'm embedding Zendesk web widget in a react component to be used in different parts of the same application. I need to replace the event handler function in order to do different things based on the current section of the application.

https://developer.zendesk.com/api-reference/widget/core/#on-userevent

4 replies

Eric27
  • November 23, 2021
Hey Stefania,

To confirm you're looking to change the userEvent that will fire the function depending on what part of the app the user is in? 

Stefania11
  • Author
  • November 24, 2021

yes, or even better, I would expect to have a way to turn off the event listening on component unmount. 


Eric27
  • November 24, 2021
Hey Stefania,

Thanks for the clarification! If you were to implement the Web Widget as its own component, you'd be able to control all of this logic. You can check out this gist showing an example of implementing this. You'd then be able to handle the web widget from within your higher level components controlling the event listening and turning it off by un-mounting the web widget component.

I ran some quick tests based on your scenario and the solution seems to cover everything, but let me know if I've missed something.

  • October 12, 2023

Hi @eric27 I'm facing the same issue as reported in this thread but with the window.zE('webWidget:on', 'open/close', () => {}) event listeners. I'm using window.zE('webWidget', 'reset') every time something gets updated but that doesn't seem to clean up the previous event listeners. Any work around? It seems your gist is down, so I couldn't check that.

Thanks,

Fernando