• Resolved jheartney

    (@jheartney)


    Like many users here, I’m trying to set up an automatic popup. Using the “Scripts n Styles” plugin, I’m dropping Javascript code into the header of the page I want the popup to appear on. Here’s my Javascript:

    function myFunction() {
    alert(“myFunction has fired”);
    DiviPopup.openPopup(‘myPopup’);
    }
    setTimeout(myFunction, 3000);

    I get the “myFunction has fired” alert (so I know the the Javascript is executing), but no popup.

    There’s a button on the page labeled “Show popup” which successfully shows the popup, so I know the Popups for Divi plugin is working (so tantalizing! if only I could get it to work off javascript). Any idea how to get the API call to work? I’ve tried using window.openPopup(‘myPopup’); but that doesn’t do anything either.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi jheartney.

    Same issue like me.
    Use the jquery sintaxis and it will work.
    I mean (‘#yourid’).
    Regards.

    Alejandro

    Plugin Contributor Philipp Stracker

    (@strackerphil-1)

    @aflamerich Thanks for the great input. In fact, you are right: The Popup ID is a CSS selector, which starts with a “#” (to match the id=”myPopup” attribute)

    However, I also found a different bug in the function – the plugin did transform all popup IDs to lowercase, so thee request DiviPopup.openPopup("#myPopup") still does not have any effect.

    This issue is addressed in version 1.3.0, which I’m preparing at the moment.

    Philipp ??

    Hi Philipp.

    Im using your plugin and the script function call worked fine for me.
    Just for your information.
    Great plugin by the way.

    Regards.
    Alejandro

    Thread Starter jheartney

    (@jheartney)

    I added the # sign and switched to all lowercase on the popup ID, and now it is working! Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t get Javascript API to work’ is closed to new replies.