1

Relatively new to Salesforce. I'm building a Community Pages site, and I built a custom template in a Lightning Component Bundle. I want to set an onclick event that works on the entire page area that fires a method on a LWC within the template. I found a tutorial that does almost exactly what I need:

https://salesforcediaries.com/2019/09/21/firing-a-method-in-lightning-web-component-from-parent-aura-component/

That works, but that relies on importing the LWC directly into the Aura component. I'm using {!v.body} in the template and using the Builder tool to drag LWCs into the body area of the template. So is there a way to target the LWC from the Aura parent, but the LWC that's been added in the builder to the {!v.body} area instead of directly?

1 Answer 1

0

You can create a listener inside your LWC component and fire a message from Aura. For this you can either use LMS or window.dispatchEvent

2
  • Can you elaborate any? I've been trying to make window.dispatchEvent work with the LWC and parent Aura template and I've had no luck.
    – KC2020
    Commented Nov 30, 2020 at 19:58
  • Can you please share your code so that i can check where exactly its going wrong. Commented Dec 1, 2020 at 1:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .