function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arjun Mohan 6Arjun Mohan 6 

Reuse Components in lightning

Hi All,

I have developed a Reusable Dropdown Component where in admins can select the datasource ,dropdown type(Single select or multi select) based on requirement.

If i us ethe same component twice in same page then the latest value overrides the previous value.

That is
CASE 1:DropDown with Single select and data source is List of opportunities.
CASE 2:DropDown with Multi select and data source is List of Contacts.

Thanks
Arjun.M
Leo10Leo10
Hi Arjun Mohan

At First, you have to create a wrapper class to store the details of opportunities. Since it is not static your values won't override. 

Thank you
Arjun Mohan 6Arjun Mohan 6
So what is the use of component then if it cannot give different instances ?
Greg_ThomsonGreg_Thomson
Arjun Mohan,

I had a similar problem in the past that may be the problem you are encoutering. I was using the id field and accessing it through javascript by it's ID.  The problem is that if there are multiple instances of your component on the same page, your code will potentially reach outside of it's component and interact with the field from the other component with the same id. I had to switch all of my code to use aura:id and cmp.find.

Here is the documentation: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_find_by_id.htm

Greg Thomson
Lightframe.co
Leo10Leo10
Hi,
There is a solution in below post of how to use multiple instances of component on VF page :
https://developer.salesforce.com/forums?id=906F000000097wpIAA
 
Arjun Mohan 6Arjun Mohan 6
Hi Greg Thomson,

Thanks For your Reply,

I can give Aura:ID but as am using Aura:Itiration to generate the Items Aura:Id u cannot Bind.


Thanks
Arjun.M
Arjun Mohan 6Arjun Mohan 6
Hi NABEEL KT,

Thanks For your reply,But am not using VF pages.

Thanks
Arjun.M