Created
October 29, 2020 03:02
-
-
Save sbutterfield/c2938ba91c577aebd212d224e18ccb1b to your computer and use it in GitHub Desktop.
IFrameLWCFlowAttributeChangeEvent.js The LWC has an embedded iFrame. I believe that the listenForMessage() reference window.addEventListener() call in my connectedCallback() is really within the this context of the iFrame, not the LWC. Therefore, when I set a value in that callback, I'm setting a different value than the one in the LWC. Which is…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, api, track } from 'lwc'; | |
import { FlowAttributeChangeEvent } from 'lightning/flowSupport'; | |
import pageUrl from '@salesforce/resourceUrl/recaptcha2'; | |
export default class GoogleCapatcha extends LightningElement { | |
navigateTo; | |
@api result = "undefined"; | |
connectedCallback(){ | |
var self = this; | |
this.navigateTo = pageUrl; | |
window.addEventListener("message", function(message) { | |
self.result = (message.data === "captcha success") ? "true" : "false"; | |
self.dispatchEvent(new FlowAttributeChangeEvent('result', self.result)); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment