Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I use sb admin2, but i don't know that side bar is not working because of metis menu

Tags:

jquery

my side bar is not working.

  • No collpase
  • No resize

because

Uncaught TypeError: undefined is not a function sb-admin-2.js:3(anonymous function) sb-admin-2.js:3j jquery.js:3094k.fireWith jquery.js:3206n.extend.ready jquery.js:3412I jquery.js:3428
Uncaught TypeError: undefined is not a function (index):679(anonymous function) (index):679fire jquery.js:974self.fireWith jquery.js:1084jQuery.extend.ready jquery.js:406DOMContentLoaded

I think that In sb-admin-2.js,

$(function() {

    $('#side-menu').metisMenu();

});

is not working and Uncaught TypeError: undefined is not a function

I hope... I will be helped...

like image 536
Peter JU Avatar asked Oct 14 '25 03:10

Peter JU


2 Answers

Make sure you have loaded jquery first, then sb-admin-2.js. Also make sure you only load them once.

I had the same problem and found that I had accidentally loaded both jquery and sb-admin-2.js twice, once directly with a tag and once as part of a bundle of multiple javascript files. I think loading jquery twice was the culprit in my case.

like image 61
angularsen Avatar answered Oct 16 '25 20:10

angularsen


Call Metis after the view is initialised and also Make sure you have the ordered your JS libraries in correct order. For me the sequence is as follows:

<script src="/js/jquery.js"></script>
<script src="/js/jquery.3.1.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="/assets/global/plugins/select2/js/select2.js" type="text/javascript"></script>
like image 37
M.J Avatar answered Oct 16 '25 21:10

M.J



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!