Skip to main content
Documentation/Developers/APIs/Popups API

Popups API

BreakdancePopup.runAction() lets third-party JavaScript open or close an included, initialized front-end popup.

Find the Popup ID

  1. Open Breakdance > Popups in WordPress.
  2. Hover over the popup's name to reveal its ID next to the name. You can also read it from the edit link (post=123).
  3. Use that WordPress post ID in the API call.
Popup post ID revealed by hovering its row in the WordPress Popups list
Popup post ID revealed by hovering its row in the WordPress Popups list

Actions

JavaScript
BreakdancePopup.runAction(123, 'open');
BreakdancePopup.runAction(123, 'close');

runAction(popupId, action = 'open') accepts numeric/string IDs and explicit open/close, with no meaningful return. It does nothing in the builder or when the instance is absent; location/loading conditions still determine inclusion.

Custom Trigger

Add data-popup-open="123" to a button and run after document/popup scripts load:

JavaScript
window.addEventListener('load', () => {
  document.querySelectorAll('[data-popup-open]').forEach((button) => {
    button.addEventListener('click', (event) => {
      const popupId = event.currentTarget.dataset.popupOpen;
      if (!/^d+$/.test(popupId || '')) return;
      if (!window.BreakdancePopup) return;
      event.preventDefault();
      window.BreakdancePopup.runAction(popupId, 'open');
    });
  });
});

currentTarget handles clicks on nested icons. Missing behavior requires checking ID, inclusion, script order, and console errors. Standard triggers can use built-in popup link actions.