Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: $(...).tabs is not a function

I think there is a strange problem with jquery I got this exception when page load here is my markup :

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="../Layouts/en-us/css/custom.css" rel="stylesheet" />

<link href="../Layouts/en-us/css/jquery-ui.css" rel="stylesheet" />



<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script src="../ckeditor/ckeditor.js"></script>
<script src="../ckeditor/adapters/jquery.js"></script>
<script src="/Layouts/en-us/js/jquery-ui.min.js"></script>
</asp:Content>

here is the function that causes error

$(function () {
    $("#tabs").tabs();

    if ($("#ListBoxPages").val() == null) {
        $("#tabs").css("display", "none");
    }

    $("#ListBoxPages").change(function () {
        $("#tabs").css("display", "block");
    });

});

All relative paths to Layouts and jquery were copied from another markup which works pretty fine with no error

like image 775
Ibrahim Amer Avatar asked Jul 02 '15 08:07

Ibrahim Amer


2 Answers

I can see that you are loading jquery twice so try to remove that

<script src="/Layouts/en-us/js/jquery-ui.min.js" />

and keep only -

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" />

then use below code in place of your function (First check by changes in this function then try with removing that jquery-ui.min.js)

$( document ).ready(function() {
        $("#tabs").tabs();
        if ($("#ListBoxPages").val() == null) {
            $("#tabs").css("display", "none");
        }
        $("#ListBoxPages").change(function () {
            $("#tabs").css("display", "block");
        });
});
like image 168
Shirish Avatar answered Nov 03 '22 12:11

Shirish


$("#tabs").tabs(); requires Jquery.UI just include

<script src="/Layouts/en-us/js/jquery-ui.min.js" />

or use CDN

<scriptsrc="https://code.jquery.com/ui/1.12.1/jquery-ui.js"integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30="crossorigin="anonymous"></script>
like image 31
Basit Avatar answered Nov 03 '22 11:11

Basit