• #66346
    Salesforce | Yogesh Yogesh #5
    Forcetalks

    How can we use same aura:id for multiple Salesforce lightning tags in a component?

    How can we use same aura:id for multiple Salesforce lightning tags in a component?

     

    #66387
    Salesforce | Deepak Deepak #4
    Forcetalks

    Presuming that you’re dynamically creating components (e.g. c1 and c2), you have total control over the aura:id. A component cannot define its own aura:id, only the aura:id for children within itself. From here, it follows that you’re trying to figure out what type of component you’re dealing with. For that, we use Component#getType. This tells you exactly what type of component you’re dealing with.

    For example:

    var c2 = component.find(“child2”);
    if(c2.getType() === “c:someComponent”) { …
    Alternatively, if you’re exposing actual aura:method references, you can also check for the presence of the function before calling it:

    var c2 = component.find(“child2”);
    if(c2.someMethod) { …
    Finally, if you are using interfaces, you can also check if a component is a type of interface:

    if(c2.isInstanceOf(“c:interfaceName”)) { …

Viewing 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2020 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?