How to keep id's when making new layouts

Helo, I'd like to know how to keep the ID when I make new layouts. Every time I need to make a new layout, It is imposible to keep in the new layout the Id of the whole elements in the previous layout. This is very weird because if I have 100 elements with their id's and I need to make four layouts, ¿I will have to make 400 new id's?????
It seems very weird so, I'm wondering that maybe there is another way to solve this issue.
I give a graphic example for better understanding.
Thanks!

1 Like

in Hype the way to go is to use a class.

and query via:
sceneElement.querySelector('.yourClass')

2 Likes

With sceneElement being…

var sceneElement = document.getElementById(hypeDocument.currentSceneId());
2 Likes

Which means

You will be querying the current scene for an element which has that class.

This works on layouts as they are effectively different scenes.

All scenes/layouts are contained by the document/HypeDocument.
Therefore any ID assigned to an element in a scene/layout can only be assigned once.

The document/HypeDocument as the ultimate Parent will be confused by you mixing the children up with the same id.


Notes:

Child Elements can have many class names and you can query for any or all of them.
Child Elements on a scene/layout can share the same class names.
It does not look like you are doing this but be aware if you do, your query Selector syntax would need to change so it obtains the correct element with that class name on the scene

2 Likes

ok, thanks to all of you, finally I could solve the issue!