ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

EE Parsing object literals in javascript

July 21, 2009 2:56pm

Subscribe [6]
  • #1 / Jul 21, 2009 2:56pm

    Avi Block

    27 posts

    This happened one time randomly for me, on a production site last year. It happened again this year, thankfully not on a production site, but I still would like an answer.

    Basically I had some code in my javascript like:

    $("#register-login").dialog({draggable:true, dialogClass:"rl-modal modal", modal: true})

    This was working, without a hitch, for a few weeks now. All of a sudden, I refresh the page and, boom!
    Took me about three hours to figure out that all the options were blank.

    Now this happened to me last year on a production site. Boy was I sweating, when no javascript was working. I actually went and rewrote the code so it didn’t use these object literals.

    Eventually I realized, that if I just moved one of the brackets to a new line, EE doesn’t try to “parse” them. So this time, as soon as I realized what was going on, I fixed the problem.

    So, obviously, EE thinks that these are template variables. I can dig that. The problem is why would it randomly change like that?

  • #2 / Jul 21, 2009 3:02pm

    Ingmar

    29245 posts

    It shouldn’t change randomly, no. Did anything change? A new version or build of EE, perhaps? Or did you change the template type?

  • #3 / Jul 21, 2009 3:05pm

    Avi Block

    27 posts

    As far as I know, nothing changed but the time. It is slightly possible that something on the server change, as my host did just upgrade recently, and maybe they just did it again, but I’m not sure why that anyway would have an effect.
    None of the other developers on this site were doing anything at the time either, just me. The only thing I did right before was change the cookie domain, and then log in.

  • #4 / Jul 21, 2009 3:07pm

    Ingmar

    29245 posts

    I see; in that case, my advice would be to keep an eye out for it, and let us know if it happens again. Not sure there’s much else to do if we can’t reproduce the behavior.

  • #5 / Aug 11, 2009 8:47am

    biberltd

    54 posts

    Right now it is happening to us after 1.6.8 update.. If we can figure out what the real issue is we’ll post it here.

    Take care

  • #6 / Aug 11, 2009 10:09am

    Sue Crocker

    26054 posts

    biberltd, is this something happening all the time, or just occasionally?

  • #7 / Aug 11, 2009 10:23am

    biberltd

    54 posts

    It’s only for this time. For some reason EE changed the way it parses JS templates. We couldn’t find the reason for this behavior but now we are moving all JS and CSS files out of templating system. We are creating actual files in subdomains.

    It’s probably going to work and also it is going to be a more optimized way to handle JS and CSS files. We’ll let you know.

    Oh by the way this issue occured right after 1.6.8 update. There is may be some updated configuration withn this update that we are not aware of.

  • #8 / Aug 11, 2009 10:42am

    biberltd

    54 posts

    ok, now. that works for eternal JS files. For internals, if there is this pattern in a single line {} then it should be broken into multiple lines like this
    {
    }

    However; this isn’t a real solution and we are having a very hard time to find one without being able to identify the reason why this issues is occuring. Well, if you can reproduce the issue we’ll be glad if you let us know. If we find what exactly was the problem we’ll also let you know.

    Take care.

  • #9 / Aug 11, 2009 3:31pm

    Lisa Wess

    20502 posts

    Make sure you have error output in Template and Debugging set to 1.  Also try the protect_javascript hidden variable.

  • #10 / Aug 17, 2009 10:23pm

    jbcobbs

    53 posts

    I had the same issue. Making the js external worked.

  • #11 / Aug 18, 2009 1:37am

    John Henry Donovan

    12339 posts

    Glad that worked for you jbcobbs. How are you getting on biberltd, after Lisa’s advice?

  • #12 / Aug 18, 2009 3:25am

    biberltd

    54 posts

    We have already taken all the JS files to a CDN. So we actualy don’t have the problem anymore but we were trying to figure out why the problem was happening and so far we are unable to figure that out. We dropped the issue aside for couple days since we have other deadlines to catch. As soon as we figure out why this is happening (and of course if we can) we’ll post the details 😊.

    Take care,

    Can Berkol

  • #13 / Aug 18, 2009 3:32am

    John Henry Donovan

    12339 posts

    Thanks for the update.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases