1

I'm new to EE.

My problem is that I can't load jQuery to my template.

I created a template in global/footer, then added just before the </body> tag the following:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="{path='scripts/bootstrap'}"></script>
<script src="{path='scripts/brand'}"></script>

I also tried to link the file with {theme_folder}.

I searched everywhere (here, EE Forums...), seems like nobody has the same problem.

Maybe I just don't see it and it's really a simple error in my code.

Thanks in advance.

  • Does it work without using templates ?? Try to use your browser and analyze the source code, to check if the paths are correct. – Stéphane Feb 13 '14 at 19:12
  • I'll try. It doesn't work even if I just paste the code directly in section tag. – atorscho Feb 14 '14 at 14:01
2

You don't mention if the text/code renders to the screen? If so you can debug in the browser inspector to find out the issue with paths or JS errors that may be preventing JQuery to run. So I'm assuming it's not rendering to the screen and based on the information you've provided, you have a "global" template group with a template called "footer".

Try accessing that directly on your URL /index.php/global/footer. That should render out that template.

If it's not, are you using external files or editing the template directly in EE interface (Database)?

If the template is an external file, are you sure the path is correct? Are any of your templates correctly appearing via external files?

If you can get the individual template to render, there's something wrong with your parent/root template and including the /global/footer template. Assuming you have a template group called "site" and a template called "index" and that this template group is set to your default, ensure you have:

{embed=global/footer}

...and you should be good to go.

On the assumption it is (and was) rendering the JavaScript include line to the browser output and it's the other lines you're struggling with, you're referencing the path tag, which means these are also templates. So you have a template group called "scripts" and templates called "bootstrap" and "brand". These are templates, not pointing to external files elsewhere in your build - is this intentional? You mentioned {theme_folder}, so I assume not.

Start by hard coding the URL: /themes/site_themes//scripts/bootstrap.js (assuming that URL is correct for your server). If that works, convert to a variable (in your config.php file) which you can then utilise throughout your site and templates.

| improve this answer | |
  • I have in "global" default template group: index, header, footer. The header and footer are included in index via embed, just like you did. But even if the source code shows that JS have been successfully included in script it still doesn't work. I'm editing templates in Admin Area, not in files. – atorscho Feb 14 '14 at 14:03
  • The templates "bootstrap" and "brand" are of JS type. I saw it on the other post here in StackExchange. I tried also using the {theme_folder} and include it with files - still not working though the source code shows it correctly (the path and the content of the file). P.S.: The EE is in the /ee/ folder of my site. If it changes something... – atorscho Feb 14 '14 at 14:07
  • Try to check the EE config file to verify the site root paths settings. Inside the index.php too. – Stéphane Feb 14 '14 at 18:35
  • "URL to the root directory of your site": "mysite.com/ee" Right, isn't it? – atorscho Feb 15 '14 at 15:13
  • No, that sounds like your system folder for EE, not the root of your site (e.g. your homepage URL). You stated that the JQuery isn't loading, can you clarify if you mean your custom JS or the actual JQuery library? You also state the source is showing the files correctly, so there's nothing wrong with the pathing. No errors in the JS I assume? – Peter Lewis Feb 16 '14 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.