stepbysteptomathpro
stepbysteptomathpro

Reputation: 475

What causes this: Uncaught TypeError: $ is not a function?

I know that this question has already been asked a lot, but none of the solutions suggested worked for me.

I think the problem lies within the jQuery references, but I lack the knowledge to know what is wrong.

Here's the references:

<script src="/tools/scripts/apps/cpc.js"></script>
<script src="/tools/Scripts/tools/jquery/v2_1_4/jquery-2.1.4.min.js"></script>
<script src="/tools/scripts/tools/jqueryui/jquery-ui.min.js"></script>
<script src="/tools/scripts/tools/jqgrid/js/i18n/grid.locale-de.js"></script>
<script src="/tools/scripts/tools/jqgrid/js/jquery.jqGrid_5_3_0.min.js"></script>
<script src="/tools/scripts/tools/jqgrid/js/jszip.min.js"></script>
<script src="/tools/Scripts/tools/date.js"></script>
<script src="/tools/scripts/apps/3rdParties/startPage3rdParties.js"></script>
<script src="/tools/Scripts/tools/jquerymap/dist/jquery.vmap.min.js"></script>
<script src="/tools/Scripts/tools/jquerymap/dist/maps/jquery.vmap.world.js"></script>

This is the codepart where it says jQuery is not a function:

jQuery(document).ready(function($){

    // $("#sideNavBox").hide();
    //$("#contentBox").css("margin-left:20px!important;");


    writeAction();
    writeTabs();

    $("#DeltaPlaceHolderPageTitleInTitleArea").html("Counterparties");
    $(".ms-webpartPage-root").css("border-spacing", "0px");

    $(".ms-breadcrumb-top").hide();
    $(".ms-mpSearchBox").hide();
    //$("#titleAreaRow").hide();

    $("#Ribbon.ListForm.Display.Manage.EditItem-Large").hide();
    $("#fullscreenmode").click().trigger("click");
    // startAutoLaunch();


});

I tried replacing jQuery with $, but it didn't change anything.

I also tried to define

var jQ = jQuery.noConflict(true);

and using jQ(document).ready(function($){

but that didn't work either.

Can someone help me with this issue?

Upvotes: 0

Views: 5043

Answers (1)

NickHTTPS
NickHTTPS

Reputation: 799

The order in which your scripts are loaded matters. Try to put jquery library first and all its dependencies:

<script src="/tools/Scripts/tools/jquery/v2_1_4/jquery-2.1.4.min.js"></script>
<script src="/tools/scripts/tools/jqueryui/jquery-ui.min.js"></script>
<script src="/tools/scripts/tools/jqgrid/js/i18n/grid.locale-de.js"></script>
<script src="/tools/scripts/tools/jqgrid/js/jquery.jqGrid_5_3_0.min.js"></script>
<script src="/tools/scripts/tools/jqgrid/js/jszip.min.js"></script>
<script src="/tools/Scripts/tools/date.js"></script>
<script src="/tools/scripts/apps/3rdParties/startPage3rdParties.js"></script>
<script src="/tools/Scripts/tools/jquerymap/dist/jquery.vmap.min.js"></script>
<script src="/tools/Scripts/tools/jquerymap/dist/maps/jquery.vmap.world.js"></script>

<!-- your script should be last -->

<script src="/tools/scripts/apps/cpc.js"></script>

Also from the docs:

// Shorthand for $( document ).ready()
$(function() {
    console.log( "ready!" );
});

Upvotes: 1

Related Questions