Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap collapse() function not working

I'm using bootstrap to collapse parts of my website. It all works fine. But when I try to control the behaviour manually by javascript, it does not work

for example when I do this:

 $(".collapse").collapse('hide');

or exactly this:

  $(".collapse").each(function () {
            if (localStorage.getItem(this.id)) {
                $(this).collapse('hide');
            }

it does not work. I get this error: Object doesn't support property or method 'collapse' bootstrap.

I saw similar examples online. What am I doing wrong? Thanks for any help.

Update:

The Problem was related to different jquery-versions in my asp.net mvc project. Removing this line of code from _Layout.cshtml fixed it:

   @Scripts.Render("~/bundles/jquery")
like image 827
DanielG Avatar asked Nov 11 '22 22:11

DanielG


1 Answers

The Problem was related to different jquery-versions in my asp.net mvc project. Removing this line of code from _Layout.cshtml fixed it:

@Scripts.Render("~/bundles/jquery")
like image 67
DanielG Avatar answered Nov 15 '22 00:11

DanielG