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.

Javascripts issues

June 13, 2008 3:11pm

Subscribe [3]
  • #1 / Jun 13, 2008 3:11pm

    S. Lee Ware

    39 posts

    Moderator’s note: Split from this thread.

    I too am having this problem, and am glad I have found this thread.

    I am running 1.6.3, Build:  20080421
    My hosting for this project is through HostGator.

    I have not upgraded, but am starting a fresh site with this build.

    The site was fully designed and coded, with html, css, and javascript all standards compliant and error free, and in perfect working order on a test server.

    One of my first acts on the fresh install was to turn on the Debug preference to ‘1’, and set ‘Display SQL queries’ and ‘display template debugging’ to ‘yes’.

    Once I began moving these files into EE templates, I noted a series of problems (this is my 5th EE site, so I am not totally inexperienced).  What follows is a walkthrough of my experience:

    1) I set up javascript files as external files in a javascript directory on the server to begin, planning to move then into template type ‘javascript’ templates later in the process.  This is still with debug preferences set to 1.

    2) at some point last evening, in the midst of working on a separate issue, I set debug preferences to 0, and set ‘Display SQL queries’ and ‘display template debugging’ to ‘no’ to simply shorten the outputted screen height a bit ... not thinking much about it at the time.

    3) I didn’t notice that the javascript had stopped working right away, and when I did discover that there was a problem, I didn’t even think it could be the debug preferences and instead went about looking for the problem in possible code / template changes that I had made.  I eventually found that while the full javascript files were in separate external files in a directory on the server, I was using some global variables to hold some javascript ‘triggers’ common across the site at the bottom of the templates.  These ‘triggers’ were having everything between their { brackets } removed by EE upon output, and therefore the javascript functions were not getting properly called.  This setup had been working fine previously, and were not fixed when moving those triggers directly into the template, rather than calling the global variable.  I puzzled over what might have changed until I found this thread ...

    4) Reading about the connection with the debug preferences in this thread, I changed the setting back to ‘1’, and all problems are solved - that is, the javascript ‘triggers’ are being outputted properly (not stripped of content between the { brackets }).  I should note, this setting affects all A-grade browsers on pc, whether logged into the site or logged out - so even when logged out (and the debugging is not being shown to you) the setting has effect.  If it is set to ‘1’, everything works.  If it is set to ‘0’, javascript { bracketed } code is stripped out.

    In conclusion, I am happy to do what I can to support a resolution to this issue, as I don’t want to hand this project over to my clients with debugging info streaming onto their pages when logged in as super-admins.

    The ideal solution will allow me to run javascripts through EE as javascript template types smoothly, with both debugging set to either 0, 1, or 2 - though by far the most important to me right now is getting things to work with it set to ‘0’, since that is what currently doesn’t work, and the state of things desired for delivering the project to my client.

    —edited for clarity—L.A.

  • #2 / Jun 13, 2008 4:26pm

    S. Lee Ware

    39 posts

    This is probably a separate issue, but, with things basically working and the debug setting to ‘1’ - when I link to an external javscript file in a directory on the server, everything is fine, as is the case described in my previous post.  However, when I put the exact same javascript file in a template with template type ‘javascript’ and link to it in exactly the same way ... some javascript documents don’t work.

    Example:

    <scr!pt type="text/javascript" src="/javascript/code.js"></scr!pt>

    The above code works just fine by calling an external (to EE) .js file.

    <scr!pt type="text/javascript" src="{path=javascript/code.js}"></scr!pt>

    The above code DOES NOT work, where ‘javascript’ is a template group, and ‘code.js’ is an EE template containing the exact same code as the external file.

    Some scripts (even larger in file size) do work this way, but some don’t.  I wonder where the differences are coming from and what to do about it.

  • #3 / Jun 15, 2008 11:16am

    Robin Sowell

    13255 posts

    For the second issue- if you switch the template type to static, does it work?  And I’m going to bump Derek on this on since he’s already dug into the issue.

    And the first issue basically boils down to- it doesn’t work w/debug 0, does work otherwise.  Correct?

  • #4 / Jun 15, 2008 11:19am

    Robin Sowell

    13255 posts

    And a second note- D.Jones has talked about the debug issue- in this thread, for example.

    (If) your debug setting in Output and Debugging Preferences set to 0 (all errors hidden)?  That will cause ExpressionEngine to aggressively “hide” any text that resembles an unparsed ExpressionEngine variable, which sounds like what is happening.  I always keep the debug setting at 1, incidentally, as if there are errors occurring, someone should be aware so that they can be addressed and Super Admins…

    That’s likely what’s happening and leaving debug to 1 is a good idea.  But I’ll poke the dev crew on it in either case.

  • #5 / Jun 16, 2008 11:32am

    Robin Sowell

    13255 posts

    OK- talked to the crew.  The general consensus is- it’s a good idea to leave debug to 1 in order to identify errors.  If there are folks you’d prefer not to see errors, creating a custom member group for them and leaving a superadmin who can spot errors is the best idea.

    If that is not an option- altering the js so that opening and closing brackets are not on the same line should solve the issue.

    Make sense?  And are we good to close this on out?

  • #6 / Jun 17, 2008 9:35pm

    S. Lee Ware

    39 posts

    Thanks so much Robin for all your attention to this issue - I must have somehow “unsubscribed” from this thread, as I didn’t receive reply email notices and assumed the thread had died.  I am now so deep in other issues relating to this project that I will have to revisit the javascript issue a bit later, but again, thanks for your help and yes, let us consider this issue closed.

  • #7 / Jun 18, 2008 6:14am

    Ingmar

    29245 posts

    Very well. You can always start a new one, of course 😊 Closing.

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

ExpressionEngine News!

#eecms, #events, #releases