Join the Webstudio community

Updated 3 weeks ago

I have a script inside a content embed but it doesnt seem to work

does the content embed support scripts
Attachment
image.png
A
O
J
43 comments
seems to work in app but not on live
Not super clear where to find what, link to live, also why your script is inside the content embed which is for embedding external html coming from 3rd party
yeah we sometimes have cms data that contains calculators or small functional content
link to live
https://www.casinomeerkat.com/blogs/hedge-bet-calculator
page on WS is blog template"
is there any way around this. as my pages are dynamic
i ran it through a html embed aswell. same issue
don't think we tested this, maybe @John Siciliano tested
I recall at one point we had an issue with dom content event not getting called on dynamic pages. I'll start a test there to see if that was addressed. thought it was
though that issue, the script ran on the first load, just not navigation
in theory it should behave exactly the same as regular html embed
@AdamOBryn can you drop a console log first thing in there to see if that prints? I'd also log one of the elements and lastly a log in the event listener
updated it so clicking clear should log:

clearBtn.addEventListener('click', function() {
console.log('Clear button clicked. Resetting fields.');
originalStakeInput.value = '';
originalOddsInput.value = '';
hedgeOddsInput.value = '';
oddsFormatSelect.value = 'decimal';
resultDiv.textContent = '';
errorDiv.textContent = '';
});
should i move it to a html embed again
its currently a content embed
there appears to be two ids with calculate-btn on the page
looks like the same form is also in the footer
ah yeah i was testing the 2 types of content looks like i didny publish after removing it
just pushed again
should be 1 now πŸ˜„
right now its content embed shall i change to html embed
I would try two things

minimal reproduction of this
try using type module instead of IIFE
don't do this. "document.addEventListener('DOMContentLoaded',"
updateing with the type module
I still see iife and no module.. maybe cache
Attachment
Screenshot_2024-12-19_at_1.44.56_PM.png
hmmm. something is causing a re render on the html
im going to clone the project and reduce it to as little as possible
great.. it works on a clone. all i did was delete every page but that page. doubt that was it but ill try again without deleting
i wonder if any of the custom head code is messing with it. possibly that head code is only allowed to run on your domains so its not impacting my clone?
hmm let me remove its just hotjar and google tag. but i think it wasnt working before i added them
will see if google tag was the issue
hmm google tag seems fine. probably hotjar
cheers guys πŸ˜„ #
hmm odd. it's causing some sort of rerender which I think is the issue
Add a reply
Sign up and join the conversation on Discord