Closed noozo closed 2 months ago
Got around it by explicitly defining the variation id in the template of the variation:
%Variation{
id: :cta,
attributes: %{},
slots: [
"""
This is my modal text
<:cta>Click this CTA</:cta>
"""
],
template: """
<.psb-variation id="cta_modal" />
"""
},
this is the way to go 👍
remember that you can also get the variation_id injected into your template by referencing :variation_id
anywhere in your template markup
I have a modal component with an optional CTA button to open it via JS, using the dialog element method (with onclick):
The problem is that the generated id will not be a valid JS variable name, and the showModal function will fail when i click the CTA button in a story:
This is the generated id, shown when clicking the error in the JS console: