Hi Experts;
I am hoping that others can comment on the htmlcomponent.onMessage handler capture events. In the following code, the htmlcomponent logs that it is ready before the page code sets its message handler. To my surprise, the message is nonetheless triggered by the event!
// Wix page code:
$w.onReady (() => {
console.log("page code ready");
$w("#iframehtml").onMessage(event => {
if (event.data.type === 'notify_ready') {
// ask the component for stuff etc
}
});
// ...
//Relevant HTMLComponent code:
window.addEventListener('load',NotifyReady);
function NotifyReady () {
console.log("html component ready and sending notify_ready");
window.parent.postMessage({ type : "notify_ready" }, "*");
}
Can anyone provide some insight into this? Is it just coincidence, or is this an expected behavior for the capture of onMessage events?
Thanks,
Jennifer