-
a just came accross an issue mby sombody has an idea how to solve that: given two div's that are conditionally shown with x-show in both divs is the same svg code with linear gradients - thoose gradients have the same id now if i hide the div thats first on the side the gradients in the scond div also disappear code to reproduce:
how can i tell alpine to differ between the two svgs? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
you can use $id to get a unique id, or just define the stuff somewhere else that isn't duplicated. the id will find the first match, which will be hidden, so it will also be hidden. So don't have the same id, either by only having that code once, or by having unique ids. |
Beta Was this translation helpful? Give feedback.
-
why is it bat tooling when i have two placements for a logo, on the real site the two swg codes arent even on the same alpine component, but if i close the menu all paths with a gradient in both components disapear. should not alpine differentiate between the html inside of each component? somehow there is a bug with this gradients i guess you can see it here: https://kaa8.stagingsdev.com/ if you toggle the menu, the logo in the hero section toggles as well though it not even in the same component. |
Beta Was this translation helpful? Give feedback.
This has nothing to do with Alpine.
Alpine is not touching your code at all and is not related to the issue.
You can remove alpine and the same issue will happen.
this is purely in how html and svg work.
The bad tooling is that it is injecting the same gradiant with the same ids in different places.
It shouldn't do that.
It should inject it once at a higher level, or give them unique ids.
Alternatively, you can load it as an svg file instead.
But this has absolutely nothing to do with Alpine.