forwarder / belco-magento2

2 stars 9 forks source link

Fire Event when Belco is ready #1

Closed wouter-toppy closed 4 years ago

wouter-toppy commented 4 years ago

In some cases we want to know when the belco widget is ready so we can do something with it. (hide it for a cookie message as an example)

right now on the initial page load (DOMhtml) there is no belco element or something, so its not possible to check for that element.

fire an event when belco is ready will allow you to listen on that event and do something because you know there is an <div id="belco-container"></div> element.

Belco.once('ready', function() {
    document.dispatchEvent(new Event('Belco_Ready'));
})

You will be able to listen to the event with:

document.addEventListener(
    'Belco_Ready',
    function (e) {
        // $('#belco-container') is available
    },
    false
);
wouter-toppy commented 4 years ago

See pull #2

wouter-toppy commented 4 years ago

Any update here?

Pagebakers commented 4 years ago

Sorry Wouter, we totally missed this issue.

I'm going to close this issue and continue the discussion in the PR. #2