Announcement
Collapse
No announcement yet.
JS comments
Collapse
X
-
Hi dcarver , I see what you mean. I remember now that this happened to me on attribute prompts. I frequently put scripts into the prompts for various reasons, and if I have a comment in the script, it messes everything up. In this case it's actually happening on input, when I paste the entire prompt into the prompt field it gets turned into one long line. Then when I click update and the script gets commented out.
-
That's to be expected if you are rendering that code as HTML. Newlines in HTML are rendered as a space. That shouldn't stop JS from working. If I put your code example in a script tag and do an alert( x ), I get an alert with a value of 5 which I would expect. I'd imagine if you looked at the source of the generated template you'd see the newline is still there after the comment.
Leave a comment:
-
I've run into similar issues, in my case the problem was usually that whitespace got removed, so the single-line comment accidentally commented out the following lines. Something like:
Code:// this is a comment let x = 5;
Code:// this is a comment let x = 5;
Leave a comment:
-
We don't have any limitations within Empresa in terms of handling characters. It probably had a an extra character somewhere or invalid syntax somewhere in the script would be my bet.
Leave a comment:
-
Hey David,
I put the comments back in and I can't repro this issue right now. Maybe when I pasted the JS into the page there was a character that isn't handled by Empressa and killed the script's execution or the complete script isn't rendered by Empressa?
I'll let you know if I run into the issue again.
Scott
Leave a comment:
-
Can you post your entire script or at least a section of it where it works without the comment and doesn't work with the comment?
Leave a comment:
-
JS comments
I was adding some simple JS directly to a brand new page, no component items even, on a dev store, v5.35 Empressa. I had some comments using the //. The script wouldn't fire. I Was getting an "unknown token" type error. Script ran as expected when I removed all the comments from the script. Is there a solution to being able to retain the comments?
The raw html/script runs nicely with the comments without running through Empressa.
Is this new for Empressa v5.35? Or, a bug maybe? I am fairly sure I've been able to add comments to a script in prior versions.
ScottTags: None
Leave a comment: