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:
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

marcsublet
 
marcsublet replied on at Permalink Reply
marcsublet
It seems the problem comes from
<?php Loader::element('header_required'); ?>

if not logged in, the html shows that:
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
// HEADER_REQUIRED STARTS HERE
<!--[if lt IE 9]>
<script src="/c57/concrete/js/ie/html5-shiv.js"></script>
<script src="/c57/concrete/js/ie/respond.js"></script>
<![endif]-->
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>My Website :: Home</title>
<meta name="description" content="">
<meta name="generator" content="concrete5 - 5.7.0.1">
<script type="text/javascript">
var CCM_DISPATCHER_FILENAME = '/c57/index.php';
var CCM_CID = 1;
var CCM_EDIT_MODE = false;


No trace of jQuery or others files loaded in the header or footer
yulolimum replied on at Permalink Reply
yulolimum
Did you ever figure this out? My header_required and footer_required doesn't output a single line when logged out.
yulolimum replied on at Permalink Reply
yulolimum
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...