Loading header_required, and other javascript libraries

Permalink
My theme loads quite a few javascript files that depend on jQuery.


If I write this line above my scripts:

<?php  Loader::element('header_required'); ?>
<!-- note, did not include my own jQuery since that's in the header element of concrete5 -->
<script type="text/javascript" src="<?php echo $themepath; ?>/js/custom.js"></script>


I get the error message:
ccm.app.js line 1: Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function
pages control menu.js line 70: Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function


And my edit bar does not work (the edit button does not appear, nor does the "Dashboard" button.

If however I write that line below my scripts:

<script type="text/javascript" src="<?php echo $themepath; ?>/js/custom.js"></script>
<?php  Loader::element('header_required'); ?>


Then my edit bar and dashboard work, but now none of my custom scripts work because they rely on jQuery.

Any advice?

 
nicolechung replied on at Permalink Reply
I think the problem was in ccm.app.js it references $ as the jQuery object but my custom.js file wraps everything inside of a jQuery.noConflict wrapper:

jQuery.noConflict()(function($){
       $(document).ready(function() {
         // some jQuery javascript here      
       });
    });


Getting rid of the jQuery noConflict() helped.

$(document).ready(function() {
         // some jQuery javascript here      
       });