Question

Reloading look or dashboard using postMessage doesn't trigger message to parent window

  • 27 November 2018
  • 4 replies
  • 594 views

I have an embedded looker iframe which contains a look. I need to update the UI in the parent window after a look is reloaded (update filters and then re-run). But it looks like posting messages to the looker iframe doesn’t trigger and message back to the parent window. Is this the correct behavior? Is there a workaround for this issue?



Here a pseudo code



  // first register the listener

window.addEventListener('message', (e) => {

// I see the look iframe messages when the iframe is first loaded

// *** NOTHING is triggered after I update and reload the look

console.log(e)

})



function reload(iframe) {

// update filters

let updateJSON = JSON.stringify({

type: 'look:filters:update',

filters: { .... },

})

iframe.contentWindow.postMessage(updateJSON, '...')



// reload look

let runJSON = JSON.stringify({ type: 'look:run' })

iframe.contentWindow.postMessage(runJSON, '...')



// iframe is updated successfully, but parent window doesn't get any "message"

}



// lookerIframe is the looker iframe

reload(lookerIframe)

4 replies

Hey @Young_Zhao,



To clarify, are you using code identical to the default window.addEventListener function like the one in our docs below:






Or are we using custom logic when checking the event source and event origin?

Hi @Ellio,



Yes I am using code identical to the looker documentation. The issue is look:filters:update and look:run doesn’t trigger any message to the parent window.



I actually found a workaround for this by using iframe url to update the filter values



https://discourse.looker.com/t/override-look-filters-in-the-url/6649

I see. In this case, because we might need to get into the specifics of your javascript event scripting, I’d recommend sending an email to help.looker.com to get an email conversation started. This would allow us to better examine the in’s and out’s of your setup!

@Ellio Thanks! I will contact support.

Reply