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.

curious javascript problem - javascript isn't working when loaded from templates

December 06, 2010 5:14am

Subscribe [6]
  • #1 / Dec 06, 2010 5:14am

    Bill the Grue

    162 posts

    Hello crew.

    v2.1.1 Build:  20101020

    I’m transitioning a template to expression engine. The problem is the javascript isn’t working when I load it from a template (exact error via firebug: Syntax error on line 42 of jquery.js) However, when I load the /exact same/ javascript from a local file on the same webserver, then the javascript works as expected.

    The template is defined as a javascript type template.

    I’ve run a diff on the javascript in my template and the javascript I load from a local flatfile - there is no difference in the files.

    Any suggestions or ideas?

    Warmly,

    Bill

  • #2 / Dec 06, 2010 4:27pm

    Brandon Jones

    5500 posts

    Hi Bill,

    Make sure your Debug Preference is set to “1” in Admin > System Administration > Output and Debugging. Also, if you aren’t needing EE to parse any EE tags in your Javascript, I would simply link to the file externally instead of making it a Javascript template.

    Does that help?

  • #3 / Dec 06, 2010 4:50pm

    Bill the Grue

    162 posts

    it does help -

    I turned on template debugging as you suggested - nothing off there, the template loaded up just fine, as did all the other embeds.
    I guess grabbing the JS locally works but is this suggested best practice? I kind of like having all my stuff in one place (the db).

    Thank you for your help!

    Warmly,

    Bill

  • #4 / Dec 06, 2010 5:41pm

    Brandon Jones

    5500 posts

    Hi Bill,

    The option I suggested was Debug Preference, not Display Template Debugging. If Debug Preference is not set to 1: PHP/SQL errors shown only to Superadmins then you might see Javascript errors due to EE mistaking some of the JS for EE tags. Does that help?

  • #5 / Jan 14, 2011 11:48pm

    Jeremy Lee James

    50 posts

    Brandon Jones, you saved me from shooting myself in the head just now. I had given up hope. I kept telling myself: “but I didn’t *change* anything in my templates—how in the frack could my jQuery not be loading?!?”

    And then I saw this tip. And I turned error reporting back on to “1” and I now look forward to a long and prosperous life in front of me.

    So THANKS!

    But maybe this should be made a bug report? I can’t imagine that turning off error reporting and having it mess with the way javascript templates are parsed is the expected behavior.

  • #6 / Jan 15, 2011 12:19am

    narration

    773 posts

    Jeremy, I was kindly informed this was not-a-bug.

    Hence in addition to the bug report (it’s a bug…it hits someone hard enough to report at least once a month), I have done as requested and made a feature request of it.

    If you want to add support, that is here: http://ellislab.com/forums/viewthread/177632/


    We live in hope…;)

  • #7 / Jan 15, 2011 5:07pm

    Greg Salt

    3988 posts

    Hi Bill,

    How are you getting on with this?

    @Jeremy, Clive, thanks very much.

    Cheers

    Greg

  • #8 / Jan 18, 2011 12:00pm

    Bill the Grue

    162 posts

    Hey Greg!

    I gave up on it. I am calling the JS externally, as you suggested, and everything works as I need it to. However, no matter what level of error reporting I have on, the javascript still does not work when inside a template. Odd, that.

    I prefer to have all my files in templates, as it makes backing up a bit easier, but this really isn’t all that big of a deal 😊

    Thank you for your assistance.

    Warmly,

    Bill

  • #9 / Jan 19, 2011 12:43am

    John Henry Donovan

    12339 posts

    Thanks for the update Bill. Note you can call jQuery and plugins directly in your template now with tags from EE’s jQuery Module so that might be something to look at.

    Closing this one out for now. Feel free as always to start a new thread if you have any more questions

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

ExpressionEngine News!

#eecms, #events, #releases