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.

$(document).ready(function(){ }); not working

February 15, 2011 11:52am

Subscribe [3]
  • #1 / Feb 15, 2011 11:52am

    mattwildman

    6 posts

    I’m unable to properly load jquery in my EE2 template. My code is below. If I simply create a function with the same alert and call it through window.onload, it works. Am I not calling my javascript files correctly (I originally used google api’s but that didn’t work either)? Do I have to do something special in EE2 to use the $(document).ready?

    [script type="text/javascript" src="{path='includes/jquery.js'}"][/script]
    [script type="text/javascript" src="{path='includes/cufon-yui.js'}"][/script]
    [script type="text/javascript" src="{path='includes/avenir2.font.js'}"][/script]
    
    [script type="text/javascript"]
    
        
            $(document).ready(function() {
                    alert('foobar');
            });
    [/script]
  • #2 / Feb 15, 2011 3:52pm

    mattwildman

    6 posts

    Just realized that I didn’t need the .js extension when I reference the path name. However, still doesn’t work. Any suggestions?

  • #3 / Feb 15, 2011 4:47pm

    mattwildman

    6 posts

    Moved the files to outside EE2 and they work fine. But for future reference, what is wrong with the above code?

  • #4 / Feb 15, 2011 9:51pm

    mz91184

    100 posts

    Are your JS EE templates set as “JavaScript” in the template preferences?

    What debugging tools are you using?  Firebug?  Have you tired opening the full url to one of your JS EE templates?

    I tired integrating templates into EE when I first started but it wasn’t efficient.  When your JS files are stored as actual files you can combined them with add-ons like (http://devot-ee.com/add-ons/asset-linker/).  Maybe just my personal preference though.

  • #5 / Feb 16, 2011 9:34am

    Sue Crocker

    26054 posts

    Matt, I find it a lot easier to deal with .js and .css files for that matter, outside of EE.

    Having said that, I’m glad things are working again, and mz91184 was able to assist.

    Don’t hesitate to post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases