6

So I have a community builder page with 2 custom lightning components I've dropped into different sections - how do I make them communicate via events?

enter image description here

I know that when you have a component inside another component, I can use component events to trigger actions in the component hierarchy. And when I have 2 components within the same Lightning App, I can use APPLICATION events to trigger actions across any component in the App.

How does it work if I have components on a Lightning page? They are not nested inside the same App (we're using Community Builder), and the components aren't nested within the same hierarchy.

4

On the same page, in a community you'd be within the same domain, making your components part of the same application event level access, even if you didn't define them as part of the same application. You could of course define ExternalEvent Handlers for the "window" but that shouldn't be necessary. See the Advanced Events Example for more on this topic.

  • Thanks. I saw that link after posting the question, and realized that they weren't using a lightning app in the example (all the other examples show components within an app). I'll go give it a try :) – Jason Benkert Feb 19 '16 at 17:00
  • +1 @crmprogdev Application events should just work here and worth trying it . – Mohith Shrivastava Feb 19 '16 at 17:04
  • Testing this and it doesn't seem to be working. I get the event to fire just fine, however the component sitting next to it on the page isn't firing the action function declared in the aura:handler. – Jason Benkert Feb 26 '16 at 5:25
  • Only thing I can think of at this point is to wrap them both in a parent component, and then use an event extension to use in the sibling component. – Jason Benkert Feb 26 '16 at 5:27
  • 1
    Am pleased to hear you got it sorted Jason. Am confident that your question will be helpful to many others as people continue to begin using lightning components in Communities. – crmprogdev Feb 26 '16 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.