17
votes
How to call parent Lightning component's method in child component?
You can pass a reference to the parent into the child, so in the parent component:
<aura:method name="parentMethod" .../>
<c:child parent="{! this }" ... />
and in the child component ...
14
votes
Accepted
How do you stop an application event from propagating to another instance of the same component?
During the event bubble phase, use event.stopPropagation() to cause the component's root to be become the root node for the default phase. This means you'll need a handler at the top-level component ...
14
votes
Accepted
Refresh parent page on close of lightning quick action modal
You can try force:refreshView, which reloads all data for the view. So in addition to $A.get("e.force:closeQuickAction").fire(); add $A.get('e.force:refreshView').fire(); in your setCallback method.
(...
13
votes
Accepted
How to get parent lightning component's attribute in child component?
The framework will never have a way for you to get the parent component. That breaks encapsulation.
You have two options:
Fire an event that your containing component can listen for and act upon.
...
12
votes
Accepted
Are lightning event synchronous or asynchronous?
Are lightning event synchronous or asynchronous?
Yes.
Asynchronous
When fire() is called, the event is placed in to a queue for later execution.
Atomic
Until canceled or completed, only one event ...
12
votes
LWC : Events - When to use event.target.value & event.detail.value
You are talking about event reparenting. Check this question - event.getSource() alternative in LWC? (considering origin reparenting).
Consider below components chain in LWC:
<c:parent>
&...
12
votes
Accepted
NoErrorObjectAvailable Script error
TL;DR;
As of my experience, the most common reason why [NoErrorObjectAvailable] Script error appears is when because a custom event is handled by a ghost method, meaning a method that does not exist ...
11
votes
Accepted
The campingList JavaScript controller isn't setting the 'item' as a parameter or saving the record correctly
I ended up moving the createItem function from my helper function to the CampingListController, since Trailhead does not "ask" us to split the createItem into a helper function.
handleAddItem: ...
11
votes
Accepted
Lightning component event not fired or handled
When you use the pattern of:
<c:parent>
<c:child name="xyz" />
</c:parent>
Then you must use includeFacets="true" to make a component event from the child bubble to the parent ...
11
votes
Accepted
Send Lightning events only to nested components
You'll want to use an application event; see the application event life cycle.
The trick here is that you must call stopPropagation on your event from c:parent in order to set itself as the "root" ...
11
votes
Accepted
$A.util.removeClass happens seconds after execution
Lightning has some sort of digest cycle analogous to what you see in Angular and other front-end frameworks. When you make changes that affect the UI, they are not evaluated instantly but rather as ...
11
votes
Accepted
How to link Lightning Components using events inside a Lightning App Builder page?
Application-level events certainly are what Salesforce recommends for the use case of components that will be "App Builder siblings" and need to talk to one another.
I think you won't be able to ...
11
votes
Why EXACTLY not calling Aura.Action attribute from Lightning Controller using $A.enqueueAction()?
what EXACTLY does not work?
You may find that Locker Service will filter out some or all of the data you're trying to work with, even within your own namespace. For this reason, the two related ...
9
votes
Accepted
Lightning Web Component use Publish-Subscribe event in Community cloud
The pub-sub module checks for page references when firing events, so that the event is scoped and only in the current page.
In Communities, we do support lightning-navigation as of Spring '19: http://...
8
votes
Accepted
Event in Lightning, not working as expected
The bug in your code is at <aura:handler name="refineList" action="{! c.refineList}" event="c:contactListSearchFormEvent"/>
you must use same name that you gave in registered event <aura:...
8
votes
Accepted
event target is empty
Component:
<aura:application >
<ul>
<aura:iteration items="[1,2,3,4]" var="product" indexVar="index">
<li onclick="{!c.ShowDataOnClick}" data-row-index="{!...
8
votes
Accepted
Reliable way to clear a setInterval used by a Lightning Component?
Usually, the component does not get destroyed once you navigate to a different view. When I tested at my end it usually takes around 9 distinct navigation(eg: visiting 9 different tabs) for the ...
8
votes
Accepted
Is it possible to fire an event from a LWC and handle in another LWC which is not in containment hierarchy?
Yes. It can be achieved using the pub-sub model.
To communicate between components that aren’t in the same DOM tree, use a singleton library that follows the publish-subscribe pattern.
Refer to ...
8
votes
Accepted
How to send multiple parameters to Event in LWC
Pass a JS Object direct into detail
const selectedEvent = new CustomEvent('custevent', {
detail: {
type: "Fiat",
model:"500",
color:"white"
}
});
Access the object ...
7
votes
How to get parent lightning component's attribute in child component?
Hope this will help you out in your requirements.
Create the event.
Event: setAttributeEvent
<aura:event type="COMPONENT">
<aura:attribute name="attributeValue" type="String"/>
</...
7
votes
Accepted
Can a parent component set the attributes of a child component
You cannot directly modify a child components attribute in parent.It provides that extra layer of security when each component can only modify its own attributes.
You can do it in 3 ways
Pass an ...
7
votes
Accepted
Application Event fired by a child component doesn't flow down other child component
As stated in the documentation:
The handler for an application event won’t work if you set the name attribute in <aura:handler>. Use the name attribute only when you’re handling component ...
7
votes
Is there any meaningful difference between event.getParam("x") and event.getParams().x?
There's no difference between the two, aside from "intent". If you just need one parameter, getParam is a bit more obvious, but if you need many parameters, getParams() offers an object you ...
6
votes
Lightning Components: how to use events to detect record updates?
Actually I'm using the event force:refreshView which is doing what I want:
<aura:handler event="force:refreshView" action="{!c.forceRefreshViewHandler}"/>
and in the controller
...
6
votes
How to add listener for toast notifications?
Yes, you can get the toast information, as it is an application event, and thus propagates to all interested listeners.
Here's the code I wrote that demonstrates this:
<aura:component implements="...
6
votes
Why EXACTLY not calling Aura.Action attribute from Lightning Controller using $A.enqueueAction()?
I'll tackle the Alternatives question here:
I've got two ways to address this, because I felt the exact same pain points as you (it's so ridiculously redundant to create so many events).
First ...
6
votes
Accepted
Lightning:recordForm cancel button unresponsive
try to add oncancel event in your component.
<lightning:recordForm
objectApiName="Custom_Object__c"
recordTypeId="{!v.Applicant.recordTypeId}"
...
6
votes
Accepted
Lightning Web Components: How to handle events from grand child on the owner(eventParent) component
There is a good example of this topic on Handle Events in Lightning Web Components trailhead which discusses the same use case as you have here (and answers both your questions).
The idea is to chain ...
6
votes
Accepted
Fire an event when the page has loaded with all the assignation
renderedCallback called after every render of the component. This lifecycle hook is specific to Lightning Web Components, it isn’t from the HTML custom elements specification. This hook flows from ...
5
votes
Accepted
How do I get the Lightning Component "destroy" system event to fire?
Generally when an component/app runs in LEX, it will not get destroyed as soon as you navigate to a different view. Have a look at the post here.
Also destroying component manually has a impact too ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
lightning-events × 312lightning-aura-components × 192
lightning × 89
lightning-web-components × 70
javascript × 34
aura × 28
event × 14
apex × 10
visualforce × 9
lightning-experience × 9
lightning-datatable × 9
onchange × 9
aura-handler × 9
community × 7
lightning-recordeditform × 6
lightning-apps × 5
lightning-community × 5
locker-service × 5
javascript-controller × 5
lightninginput × 5
aura-iteration × 5
controller × 4
platform-event × 4
quickaction × 4
aura-attribute × 4