({
doInit : function(component, event, helper) {
// create a one-time use instance of the getCommunityURL action
// in the server-side controller
var action = component.get("c.getCommunityURL");
console.log("[mf] action: " + action);
var communityURL = '';
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS"){
// alert the user with the value returned from the server
alert("From server: " + response.getReturnValue());
communityURL = response.getReturnValue();
} else {
console.log(state);
}
});
$A.enqueueAction(action);
// this section handles the reCaptcha that is in the embedded VF page
// when the reCaptcha passes, make the submit button clickable
// TODO: update with correct origin for production
//let vfOrigin = "https://mflei-eventbritecommunity.cs61.force.com";
alert('[MF] communityURL: ' + communityURL);
let vfOrigin = communityURL;
window.addEventListener("message", function(event) {
console.log(event.data);
if (event.origin !== vfOrigin) {
// Not the expected origin: Reject the message!
alert('vfOrigin: ' + vfOrigin);
alert('Not the expected origin: ' + event.origin);
return;
}
if (event.data==="Unlock"){
let myButton = component.find("myButton");
myButton.set('v.disabled', false);
}
}, false);
},
Hi Margaret, Try something like below.
regardsSampath(Sampathjt@gmail.com)({
doInit : function(component, event, helper) {
// create a one-time use instance of the getCommunityURL action
// in the server-side controller
var action = component.get("c.getCommunityURL");
console.log("[mf] action: " + action);
var communityURL = '';
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS"){
// alert the user with the value returned from the server
alert("From server: " + response.getReturnValue());
communityURL = response.getReturnValue();
alert('[MF] communityURL: ' + communityURL);
let vfOrigin = communityURL;
window.addEventListener("message", function(event) {
console.log(event.data);
if (event.origin !== vfOrigin) {
// Not the expected origin: Reject the message!
alert('vfOrigin: ' + vfOrigin);
alert('Not the expected origin: ' + event.origin);
return;
}
if (event.data==="Unlock"){
let myButton = component.find("myButton");
myButton.set('v.disabled', false);
}
}, false);
} else {
console.log(state);
}
});
$A.enqueueAction(action);
},
})