How to send data from Embedded lightning component back to Visualforce page?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
I am having trouble finding this information.
I am finding lots of stuff on communicating between a lightning component and Visualforce page when the Visualforce page is embedded inside the lightning component as an iframe, which involves doing postMessages and what not.
However, my situation is that I have a Visualforce page that I put a lightning component on.
I want the user to fill out the form in the lightning component, then click 'OK', and be able to get that info back on the Visualforce page. However, I am unsure how you perform this kind of communication. The Lightning component is not in an iframe when you embed it in a Visualforce page, so doing some complicated postMessage should not be necessary.
visualforce lightning-components
add a comment |Â
up vote
2
down vote
favorite
I am having trouble finding this information.
I am finding lots of stuff on communicating between a lightning component and Visualforce page when the Visualforce page is embedded inside the lightning component as an iframe, which involves doing postMessages and what not.
However, my situation is that I have a Visualforce page that I put a lightning component on.
I want the user to fill out the form in the lightning component, then click 'OK', and be able to get that info back on the Visualforce page. However, I am unsure how you perform this kind of communication. The Lightning component is not in an iframe when you embed it in a Visualforce page, so doing some complicated postMessage should not be necessary.
visualforce lightning-components
1
You should be able to pass in a callback as an attribute when you instantiate the lightning component. I've done it before, but am not sure if Salesforce blocks this now... give me a few mins and I may get time to provide an example.
â Caspar Harmer
Sep 6 at 18:00
Sure, I'd like to see an example of this. Do I just set it up like:$Lightning.createComponent('c:myComponent','callback': someFunctionOnVFPage, function(cmp));
? Hmm... I am unsure how you then trigger that from the Lightning component?
â Tyler Dahle
Sep 6 at 18:03
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am having trouble finding this information.
I am finding lots of stuff on communicating between a lightning component and Visualforce page when the Visualforce page is embedded inside the lightning component as an iframe, which involves doing postMessages and what not.
However, my situation is that I have a Visualforce page that I put a lightning component on.
I want the user to fill out the form in the lightning component, then click 'OK', and be able to get that info back on the Visualforce page. However, I am unsure how you perform this kind of communication. The Lightning component is not in an iframe when you embed it in a Visualforce page, so doing some complicated postMessage should not be necessary.
visualforce lightning-components
I am having trouble finding this information.
I am finding lots of stuff on communicating between a lightning component and Visualforce page when the Visualforce page is embedded inside the lightning component as an iframe, which involves doing postMessages and what not.
However, my situation is that I have a Visualforce page that I put a lightning component on.
I want the user to fill out the form in the lightning component, then click 'OK', and be able to get that info back on the Visualforce page. However, I am unsure how you perform this kind of communication. The Lightning component is not in an iframe when you embed it in a Visualforce page, so doing some complicated postMessage should not be necessary.
visualforce lightning-components
asked Sep 6 at 17:55
Tyler Dahle
40419
40419
1
You should be able to pass in a callback as an attribute when you instantiate the lightning component. I've done it before, but am not sure if Salesforce blocks this now... give me a few mins and I may get time to provide an example.
â Caspar Harmer
Sep 6 at 18:00
Sure, I'd like to see an example of this. Do I just set it up like:$Lightning.createComponent('c:myComponent','callback': someFunctionOnVFPage, function(cmp));
? Hmm... I am unsure how you then trigger that from the Lightning component?
â Tyler Dahle
Sep 6 at 18:03
add a comment |Â
1
You should be able to pass in a callback as an attribute when you instantiate the lightning component. I've done it before, but am not sure if Salesforce blocks this now... give me a few mins and I may get time to provide an example.
â Caspar Harmer
Sep 6 at 18:00
Sure, I'd like to see an example of this. Do I just set it up like:$Lightning.createComponent('c:myComponent','callback': someFunctionOnVFPage, function(cmp));
? Hmm... I am unsure how you then trigger that from the Lightning component?
â Tyler Dahle
Sep 6 at 18:03
1
1
You should be able to pass in a callback as an attribute when you instantiate the lightning component. I've done it before, but am not sure if Salesforce blocks this now... give me a few mins and I may get time to provide an example.
â Caspar Harmer
Sep 6 at 18:00
You should be able to pass in a callback as an attribute when you instantiate the lightning component. I've done it before, but am not sure if Salesforce blocks this now... give me a few mins and I may get time to provide an example.
â Caspar Harmer
Sep 6 at 18:00
Sure, I'd like to see an example of this. Do I just set it up like:
$Lightning.createComponent('c:myComponent','callback': someFunctionOnVFPage, function(cmp));
? Hmm... I am unsure how you then trigger that from the Lightning component?â Tyler Dahle
Sep 6 at 18:03
Sure, I'd like to see an example of this. Do I just set it up like:
$Lightning.createComponent('c:myComponent','callback': someFunctionOnVFPage, function(cmp));
? Hmm... I am unsure how you then trigger that from the Lightning component?â Tyler Dahle
Sep 6 at 18:03
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
To communicate from the component to the VisualForce page, use a callback function. For example:
<script>
var someFunctionOnVFPage = function(param)
alert(param);
$Lightning.createComponent('c:myComponent',
'callback': someFunctionOnVFPage,
function(cmp));
In the component:
component.get('v.callback')('hey vf page!!');
Very nice, what do you put the callback to as far as attribute type goes?
â Tyler Dahle
Sep 6 at 18:16
Just make it an object... due to Javascript's type system, it can be anything, really.
â Caspar Harmer
Sep 6 at 18:19
Sweet, that works great! Thank you.
â Tyler Dahle
Sep 6 at 20:31
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
To communicate from the component to the VisualForce page, use a callback function. For example:
<script>
var someFunctionOnVFPage = function(param)
alert(param);
$Lightning.createComponent('c:myComponent',
'callback': someFunctionOnVFPage,
function(cmp));
In the component:
component.get('v.callback')('hey vf page!!');
Very nice, what do you put the callback to as far as attribute type goes?
â Tyler Dahle
Sep 6 at 18:16
Just make it an object... due to Javascript's type system, it can be anything, really.
â Caspar Harmer
Sep 6 at 18:19
Sweet, that works great! Thank you.
â Tyler Dahle
Sep 6 at 20:31
add a comment |Â
up vote
5
down vote
accepted
To communicate from the component to the VisualForce page, use a callback function. For example:
<script>
var someFunctionOnVFPage = function(param)
alert(param);
$Lightning.createComponent('c:myComponent',
'callback': someFunctionOnVFPage,
function(cmp));
In the component:
component.get('v.callback')('hey vf page!!');
Very nice, what do you put the callback to as far as attribute type goes?
â Tyler Dahle
Sep 6 at 18:16
Just make it an object... due to Javascript's type system, it can be anything, really.
â Caspar Harmer
Sep 6 at 18:19
Sweet, that works great! Thank you.
â Tyler Dahle
Sep 6 at 20:31
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
To communicate from the component to the VisualForce page, use a callback function. For example:
<script>
var someFunctionOnVFPage = function(param)
alert(param);
$Lightning.createComponent('c:myComponent',
'callback': someFunctionOnVFPage,
function(cmp));
In the component:
component.get('v.callback')('hey vf page!!');
To communicate from the component to the VisualForce page, use a callback function. For example:
<script>
var someFunctionOnVFPage = function(param)
alert(param);
$Lightning.createComponent('c:myComponent',
'callback': someFunctionOnVFPage,
function(cmp));
In the component:
component.get('v.callback')('hey vf page!!');
answered Sep 6 at 18:08
Caspar Harmer
12.1k21748
12.1k21748
Very nice, what do you put the callback to as far as attribute type goes?
â Tyler Dahle
Sep 6 at 18:16
Just make it an object... due to Javascript's type system, it can be anything, really.
â Caspar Harmer
Sep 6 at 18:19
Sweet, that works great! Thank you.
â Tyler Dahle
Sep 6 at 20:31
add a comment |Â
Very nice, what do you put the callback to as far as attribute type goes?
â Tyler Dahle
Sep 6 at 18:16
Just make it an object... due to Javascript's type system, it can be anything, really.
â Caspar Harmer
Sep 6 at 18:19
Sweet, that works great! Thank you.
â Tyler Dahle
Sep 6 at 20:31
Very nice, what do you put the callback to as far as attribute type goes?
â Tyler Dahle
Sep 6 at 18:16
Very nice, what do you put the callback to as far as attribute type goes?
â Tyler Dahle
Sep 6 at 18:16
Just make it an object... due to Javascript's type system, it can be anything, really.
â Caspar Harmer
Sep 6 at 18:19
Just make it an object... due to Javascript's type system, it can be anything, really.
â Caspar Harmer
Sep 6 at 18:19
Sweet, that works great! Thank you.
â Tyler Dahle
Sep 6 at 20:31
Sweet, that works great! Thank you.
â Tyler Dahle
Sep 6 at 20:31
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f231513%2fhow-to-send-data-from-embedded-lightning-component-back-to-visualforce-page%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You should be able to pass in a callback as an attribute when you instantiate the lightning component. I've done it before, but am not sure if Salesforce blocks this now... give me a few mins and I may get time to provide an example.
â Caspar Harmer
Sep 6 at 18:00
Sure, I'd like to see an example of this. Do I just set it up like:
$Lightning.createComponent('c:myComponent','callback': someFunctionOnVFPage, function(cmp));
? Hmm... I am unsure how you then trigger that from the Lightning component?â Tyler Dahle
Sep 6 at 18:03