I have included an LWC component inside a VF page through $Lightning.createComponent.

As per my requirement I need to call a javascript function on parent VF page on click of a button on LWC component.

my VF page:

        function callMe(someParam) {}       
        $Lightning.use("c:myApp", function() {
              function(cmp) {

my LWC Comp:

    <lightning-button label="Call Vf Method" onclick={callVfMethod}></lightning-button>

In above example. On click of "Call Vf Method" button on LWC I want to call "callMe" method on parent Visualforce page. Also I want to pass some value as parameter.

Please note that I these pages and components are accessed inside community.

  • 2
    You can't directly call the method, you have to fire an event. You can place parameters into the event detail object. See the Q&A I linked. – sfdcfox Oct 8 '20 at 13:09
  • @sfdcfox Thank you so much for pointing me to the correct post. It worked perfectly. – Kumar Roshan Oct 9 '20 at 16:43