How do I differentiate when a child LWC component is called twice in the parent component?Pass values from parent to child component on click lightningHow to populate the selected value in dynamic picklist in lightning component?How to access aura:id of a tag present in child component in a parent component controllerLightning Components: Call init method of a child component from a parent componentHow to open LWC in a new page from Record Detail Aura ComponentError when adding different Lightning Web Components to the PlaygroundLightning Web Components: How to handle events from grand child on the owner(eventParent) componentHow to access child Web Component property from parent Aura Component controller?LWC not recognizing PageRefrence changes and not displaying updated valuesHow to setup eventListener for a LWC component to receive messages from an embedded iFrame
I accidentally overwrote a Linux binary file
(11 of 11: Meta) What is Pyramid Cult's All-Time Favorite?
What costs less energy? Roll or Yaw?
Plausibility of Ice Eaters in the Arctic
Why do oscilloscopes use SMPSes instead of linear power supplies?
Acceptable to cut steak before searing?
How does "Te vas a cansar" mean "You're going to get tired"?
The equation of motion for a scalar field in curved spacetime in terms of the covariant derivative
In SQL Server, why does backward scan of clustered index cannot use parallelism?
How is this kind of structure made?
What are the advantages and disadvantages of Wand of Cure Light Wounds and Wand of Infernal Healing compared to each other?
How do I differentiate when a child LWC component is called twice in the parent component?
Understanding the point of a kölsche Witz
Am I overreacting to my team leader's unethical requests?
The cat ate your input again!
Can you castle with a "ghost" rook?
Y2K... in 2019?
Is TA-ing worth the opportunity cost?
changing number of arguments to a function in secondary evaluation
What are the conventions for transcribing Semitic languages into Greek?
Was the 2019 Lion King film made through motion capture?
Simple Stop watch which i want to extend
Are there any financial disadvantages to living significantly "below your means"?
Trying to write a shell script that keeps testing a server remotely, but it keeps falling in else statement when I logout
How do I differentiate when a child LWC component is called twice in the parent component?
Pass values from parent to child component on click lightningHow to populate the selected value in dynamic picklist in lightning component?How to access aura:id of a tag present in child component in a parent component controllerLightning Components: Call init method of a child component from a parent componentHow to open LWC in a new page from Record Detail Aura ComponentError when adding different Lightning Web Components to the PlaygroundLightning Web Components: How to handle events from grand child on the owner(eventParent) componentHow to access child Web Component property from parent Aura Component controller?LWC not recognizing PageRefrence changes and not displaying updated valuesHow to setup eventListener for a LWC component to receive messages from an embedded iFrame
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a parent component where I am calling a child component twice in LWC.
I am firing an API method in the child from the parent, but it is firing for only one child component, not the other one.
Parent component HTML markup
<template>
// First child component
<c-child-component><c-child component>
// Second child component
<c-child-component><c-child component>
</template>
Child @api
method
@api handleShowError
this.showError=true
I have made changes in the Playground. You can check here: PlayGround
lightning lightning-web-components
add a comment |
I have a parent component where I am calling a child component twice in LWC.
I am firing an API method in the child from the parent, but it is firing for only one child component, not the other one.
Parent component HTML markup
<template>
// First child component
<c-child-component><c-child component>
// Second child component
<c-child-component><c-child component>
</template>
Child @api
method
@api handleShowError
this.showError=true
I have made changes in the Playground. You can check here: PlayGround
lightning lightning-web-components
We don't have enough code to help you. As far as I can tell, this shouldn't even compile or run. Can you please create a playground that demonstrates what you're trying to achieve? Please edit the link in to your question. Thanks!
– sfdcfox
19 hours ago
@sfdcfox I have updated Playground Link. Please check it.
– sanket kumar
18 hours ago
add a comment |
I have a parent component where I am calling a child component twice in LWC.
I am firing an API method in the child from the parent, but it is firing for only one child component, not the other one.
Parent component HTML markup
<template>
// First child component
<c-child-component><c-child component>
// Second child component
<c-child-component><c-child component>
</template>
Child @api
method
@api handleShowError
this.showError=true
I have made changes in the Playground. You can check here: PlayGround
lightning lightning-web-components
I have a parent component where I am calling a child component twice in LWC.
I am firing an API method in the child from the parent, but it is firing for only one child component, not the other one.
Parent component HTML markup
<template>
// First child component
<c-child-component><c-child component>
// Second child component
<c-child-component><c-child component>
</template>
Child @api
method
@api handleShowError
this.showError=true
I have made changes in the Playground. You can check here: PlayGround
lightning lightning-web-components
lightning lightning-web-components
edited 32 mins ago
Peter Mortensen
2491 silver badge7 bronze badges
2491 silver badge7 bronze badges
asked 19 hours ago
sanket kumarsanket kumar
5,0662 gold badges6 silver badges29 bronze badges
5,0662 gold badges6 silver badges29 bronze badges
We don't have enough code to help you. As far as I can tell, this shouldn't even compile or run. Can you please create a playground that demonstrates what you're trying to achieve? Please edit the link in to your question. Thanks!
– sfdcfox
19 hours ago
@sfdcfox I have updated Playground Link. Please check it.
– sanket kumar
18 hours ago
add a comment |
We don't have enough code to help you. As far as I can tell, this shouldn't even compile or run. Can you please create a playground that demonstrates what you're trying to achieve? Please edit the link in to your question. Thanks!
– sfdcfox
19 hours ago
@sfdcfox I have updated Playground Link. Please check it.
– sanket kumar
18 hours ago
We don't have enough code to help you. As far as I can tell, this shouldn't even compile or run. Can you please create a playground that demonstrates what you're trying to achieve? Please edit the link in to your question. Thanks!
– sfdcfox
19 hours ago
We don't have enough code to help you. As far as I can tell, this shouldn't even compile or run. Can you please create a playground that demonstrates what you're trying to achieve? Please edit the link in to your question. Thanks!
– sfdcfox
19 hours ago
@sfdcfox I have updated Playground Link. Please check it.
– sanket kumar
18 hours ago
@sfdcfox I have updated Playground Link. Please check it.
– sanket kumar
18 hours ago
add a comment |
1 Answer
1
active
oldest
votes
this.template.querySelector
will identify only the 1st component/element. When you need to identify all the components/elements, you need to use querySelectorAll
.
You can try below:
this.template.querySelectorAll('c-child').forEach((comp) => comp.showError());
Also for more learning, you can check below links:
https://salesforcesas.home.blog/2019/07/25/lwc-access-templates-and-methods-of-child-components/
https://salesforcesas.home.blog/2019/07/16/lwc-selectors-identification-of-elements/
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f273158%2fhow-do-i-differentiate-when-a-child-lwc-component-is-called-twice-in-the-parent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
this.template.querySelector
will identify only the 1st component/element. When you need to identify all the components/elements, you need to use querySelectorAll
.
You can try below:
this.template.querySelectorAll('c-child').forEach((comp) => comp.showError());
Also for more learning, you can check below links:
https://salesforcesas.home.blog/2019/07/25/lwc-access-templates-and-methods-of-child-components/
https://salesforcesas.home.blog/2019/07/16/lwc-selectors-identification-of-elements/
add a comment |
this.template.querySelector
will identify only the 1st component/element. When you need to identify all the components/elements, you need to use querySelectorAll
.
You can try below:
this.template.querySelectorAll('c-child').forEach((comp) => comp.showError());
Also for more learning, you can check below links:
https://salesforcesas.home.blog/2019/07/25/lwc-access-templates-and-methods-of-child-components/
https://salesforcesas.home.blog/2019/07/16/lwc-selectors-identification-of-elements/
add a comment |
this.template.querySelector
will identify only the 1st component/element. When you need to identify all the components/elements, you need to use querySelectorAll
.
You can try below:
this.template.querySelectorAll('c-child').forEach((comp) => comp.showError());
Also for more learning, you can check below links:
https://salesforcesas.home.blog/2019/07/25/lwc-access-templates-and-methods-of-child-components/
https://salesforcesas.home.blog/2019/07/16/lwc-selectors-identification-of-elements/
this.template.querySelector
will identify only the 1st component/element. When you need to identify all the components/elements, you need to use querySelectorAll
.
You can try below:
this.template.querySelectorAll('c-child').forEach((comp) => comp.showError());
Also for more learning, you can check below links:
https://salesforcesas.home.blog/2019/07/25/lwc-access-templates-and-methods-of-child-components/
https://salesforcesas.home.blog/2019/07/16/lwc-selectors-identification-of-elements/
answered 18 hours ago
salesforce-sassalesforce-sas
4,3481 gold badge1 silver badge22 bronze badges
4,3481 gold badge1 silver badge22 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f273158%2fhow-do-i-differentiate-when-a-child-lwc-component-is-called-twice-in-the-parent%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
We don't have enough code to help you. As far as I can tell, this shouldn't even compile or run. Can you please create a playground that demonstrates what you're trying to achieve? Please edit the link in to your question. Thanks!
– sfdcfox
19 hours ago
@sfdcfox I have updated Playground Link. Please check it.
– sanket kumar
18 hours ago