Error with custom javascript file requiring jQuery
Permalink
Hi folks,
I have a problem when I try to execute custom code with jQuery functions.
I get the following error:
My page structure like is like that (head part):
with header.php
which calls my custom-code file
It seems there is an issue in the loading order of the javascript files.
Or I have to move my javascript file to another location due to changes in 5.7.
Thank you in advance for your bright lights!
marc
I have a problem when I try to execute custom code with jQuery functions.
I get the following error:
ReferenceError: Can't find variable: $
My page structure like is like that (head part):
<?php $this->inc('includes/elements/header.php'); ?>
with header.php
<?php Loader::element('header_required'); ?> <script type="text/javascript" src="<?= $this->getThemePath() ?>/includes/js/custom-script.js"></script>
which calls my custom-code file
$(document).ready(function() { // my code here… });
It seems there is an issue in the loading order of the javascript files.
Or I have to move my javascript file to another location due to changes in 5.7.
Thank you in advance for your bright lights!
marc
Did you ever figure this out? My header_required and footer_required doesn't output a single line when logged out.
My guess is in 5.7 by default, the header_required is used to output scripts/css when you are logged in. You can tell it to output libraries when logged out as well by using the Concrete5 asset manager. Here's a link:http://www.concrete5.org/documentation/developers/5.7/designing-for...
if not logged in, the html shows that:
No trace of jQuery or others files loaded in the header or footer