2

I have just downloaded mdbootstrap. Upon following the instructions for implementing a side-nav on my webpage I get the following error when I try to initialize it:

Uncaught TypeError: $(...).sideNav is not a function at index.html:133).

Kindly help. I have tried rearranging the order of my files but this doesn't seem to help.

<script type="text/javascript" src="js/mdb.min.js"></script>
<script>
  $(".button-collapse").sideNav();

  var sideNavScrollbar = document.querySelector('.custom-scrollbar');
  Ps.initialize(sideNavScrollbar);  
</script>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Dennis
  • 83
  • 1
  • 9

3 Answers3

6

Watch out, the sideNav component is only for pro users. Perhaps you try to import a premium component with the "cheap" version of mdbootstrap

enter image description here

Hadrien Delphin
  • 590
  • 1
  • 6
  • 19
0

You need to load jQuery first.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="js/mdb.min.js"></script>
<script>
  $(".button-collapse").sideNav();

  var sideNavScrollbar = document.querySelector('.custom-scrollbar');
  Ps.initialize(sideNavScrollbar);  
</script>

And make sure you refresh the file in the web browser without cache. You can refresh it by hiting Shitf + F5 in Chrome.

Mikel Granero
  • 379
  • 6
  • 15
0

You need to load jQuery sideNav first. Do like this:

$(function(){
  const Ps = new PerfectScrollbar();
  $(".button-collapse").sideNav();
  var sideNavScrollbar = document.querySelector('.custom-scrollbar');
  Ps.initialize(sideNavScrollbar);  
})
Transamunos
  • 101
  • 4