Announcement

Collapse
No announcement yet.

JS comments

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mike521w
    replied
    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.

    Leave a comment:


  • dcarver
    replied
    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:


  • Mike521w
    replied
    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;
    becomes

    Code:
    // this is a comment let x = 5;
    after newlines are removed.

    Leave a comment:


  • dcarver
    replied
    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:


  • ids
    replied
    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:


  • dcarver
    replied
    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:


  • ids
    started a topic JS comments

    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.

    Scott
Working...
X