Announcement

Collapse
No announcement yet.

JS comments

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

    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
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    #2
    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?
    David Carver
    Miva, Inc. | Software Developer

    Comment


      #3
      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


      Need to offer Shipping Insurance?
      Interactive Design Solutions https://www.myids.net
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      Competitive Rates, Custom Modules and Integrations, Store Integration
      AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
      My T-shirt Collection is mostly MivaCon T-shirts!!

      Comment


        #4
        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.
        David Carver
        Miva, Inc. | Software Developer

        Comment


          #5
          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.
          Looking for work as of March 2024! I've been a web developer for going on 20 years, with most of that time spent on Miva sites.

          Comment


            #6
            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.
            David Carver
            Miva, Inc. | Software Developer

            Comment


              #7
              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.
              Looking for work as of March 2024! I've been a web developer for going on 20 years, with most of that time spent on Miva sites.

              Comment

              Working...
              X