Unique Element ID behaviour in Version Hype 4 Pro 4.0.3 (664) vs 4.0.2 (660)

Hi, I have an application which recognizes which element is clicked by analyzing the unique element ID.

It worked fine in Hype 4 Pro 660 (and before).
But it does not work any more in Hype 4 Pro 664.

The reason seems to be, that the element handed over to a JavaScript now has a generated ID (and no longer the Unique Element ID which I had given it.

Is this a bug?
Or a feature? But what is the Unique Element ID good for, if it doesn’t belong the element anymore? :slight_smile:

(sorry, I am not able to upload the project, because it contains too many things not for the public :slight_smile: )

Thank you for any hints!

Screenshots:

  1. how it looks in the Hype editor:

  2. how the generated source looked in 660

  3. how the generated source looks in 664

I´m on 664 and there´s no problem with passing the ID to javascript. For me it looks like you didn´t assign an ID to the element… (click the rectangle and look, what the console says…)

testID.zip (12.3 KB)

Could it be that you have this Unique Element ID assigned in two separate Responsive Layouts? In that case a collision would be detected and a generated ID would be used.

If you could create a simplified Hype document where we can see this is in action (without any private stuff) that would be . great.

Thank you, Daniel. It was not another Layout, but the element is part of a symbol, and the symbol occurred several times in the project.
I rearranged the project, deleted everything I do not really need, and I got the symbol used exactly once - then it works without further problems.

But this kind of reduces the advantage of symbols. Is there no way I can use a symbol with the same unique IDs several times? I know that contradicts the notion of “unique ID”. But how do you do it otherwise?

Thank you for quick response. For me this case is solved, the above questions stay :slight_smile:

@MaxZieb did a good summary on this topic:

Thank you, Hans-Gerd!
The solution I came up with for the problem “which element was actually clicked?” goes like this:

  1. Give the element in the Identity section an additional HTML Attribute. Example: “name” = “2-cardcloth” (for the element representing the second card cloth.
  2. In the JavaScript use getElementByID with the element.id and then getAttribute(“name”).
    This solution works, too :slight_smile:
1 Like

Yes :slight_smile: this works as long as the hype-function is triggered by a click or touch-event on the element itsself!

More Info on Data-Attributes: