Javascript Listener for a Modal?

Hey hey. Im experimenting with creating a javascript listener for a pendo guide.

The idea is that when a modal opens, [class^="createAlbum_modal__"], then the pendo guide would appear.

That modal can appear on one of a dozen pages. I want to create a Sitewide guide, and then add the listener into the guides custom code javascript.

So far I have this:

function checkElement() {
    var element = document.querySelector('[class^="createAlbum_modal__"]');
    if (element) {

setInterval(checkElement, 1000);


However I am 1000% sure Ive messed up the if (element) section. Could anyone lend me a hand? 

Thank you!



1 comment
  • Try adjusting that section to this:

    if (element !== null) {

Please sign in to leave a comment.

Didn't find what you were looking for?

New post