0

I'm in a need to place a Lightning Component multiple instances on single page (such as Home Page) but I need the options or filters sticky for the component instance only.

I tried using GlobalID, but it changes with every page refresh.

Anyone have any idea how to make them sticky for an instance of the component on page?

1
  • why not use events to communicate between the components? – Itai Shmida Jun 5 '18 at 12:25
0

Global Id is not static and as you have already faced changes with every refersh.

from docs:

Every component has a unique globalId, which is the generated runtime-unique ID of the component instance. A global ID (1) is not guaranteed to be the same beyond the lifetime of a component, so it should never be relied on. A global ID can be useful to differentiate between multiple instances of a component or for debugging purposes.

So the only thing which you can try here is use html component and create there global Id manually.

<div id="{!globalId + '_footer'}"></div>

Component IDs

3
  • Problem is, I've 2 instances on page. Then I need to find which instance is which, inside that index. {globalId + '_footer'} will return different globalId. I need to find instance, and then save & retrieve the sticky options I want to put in UI for that instance of component only. – VarunC Jun 5 '18 at 8:16
  • @VarunC in globalId you can pass variable 1,2,3... so on. – Tushar Sharma Jun 5 '18 at 8:39
  • The cmp is to be placed from App Builder. I see, your point is suitable if I'm placing the component in another component and I pass the globalId as attribute value? – VarunC Jun 5 '18 at 8:42

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.