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.

Hidden Templates & Javascript...

July 04, 2007 9:29pm

Subscribe [1]
  • #1 / Jul 04, 2007 9:29pm

    Stephen Slater

    366 posts

    Is it possible to use the new hidden template feature with javascript templates?

    Either it’s not supported or I’m doing something wrong.  It breaks my javascript when I attempt to hide them.

  • #2 / Jul 04, 2007 9:47pm

    Lisa Wess

    20502 posts

    No, you can’t.

    The reason is that if you visit the template, it will not appear.  Javascript has to be presented to the browser and readable - it is parsed by the browser, not by the server.  That is the main difference between something like PHP and Javascript.

    If you can’t see it, neither can the browser.  If you call javascript as a hidden template, then the browser won’t see it.

    The exception would be if you were embedding it directly into the page - because the embed is processed by EE.

    So this won’t work:

    <script src="{path="includes/.javascript"}"></script>

    but this will work:

    {embed="includes/.javascript"}

    Where includes/.javascript has JS code:

    <script type="text/javascript">
    your js code
    </script>

    Hope that helps =)

  • #3 / Jul 04, 2007 9:50pm

    Stephen Slater

    366 posts

    Makes total sense.  Thanks for your reply.

  • #4 / Jul 04, 2007 9:51pm

    Lisa Wess

    20502 posts

    My pleasure. =)

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

ExpressionEngine News!

#eecms, #events, #releases