vgs pro asked 6 years ago


Hi Team, im using MDBPro, first of all, you did a very good job! Im facing an issue were I do not understand how you normally overcome this problem. When loading my site, FF Console says:
TypeError: body is null[Weitere Informationen] mdb.js:13861:9
 Waves.init https://localhost:444/libs/js/mdb.js:13861:9
which leads to
body.addEventListener('mousedown', showEffect, false);
and finally
Waves.init = function (options) {
 var body = document.body;
so far, so good. document.body is null, thatswhy the waves method throws an exception (and mouse over waves effects do not work..)... But I am the only one who gets this error? My *.js files are loaded in html head, of course, but obviously the method is called prior the DOM has a body element. Maybe I should put the script tags into END OF body, but thats a very bad design from my point of view. Does anybody else has these problems? Whats your suggestion for this? Thanks
<html>
<head>
 ...
   <script src="/libs/js/popper.js" type="text/javascript"></script>
   <script src="/libs/js/jquery-3.2.1.js" type="text/javascript"></script>
   <script src="/libs/js/bootstrap.js" type="text/javascript"></script>
   <script src="/libs/js/mdb.js" type="text/javascript"></script>
</head>

<body>
...
</body>
</html>
 

Bartłomiej Malanowski staff commented 6 years ago

Try to put your js files to the end of body and let me know if problem persists

vgs pro answered 6 years ago


Hello, yes, as suspected this does solve the error. Nevertheless it would be much better from my point of view to have a kind of "initialization method" that can be called just after the page was build up. I dont like to have js references spread over the whole document. Best regards, VG

Bartłomiej Malanowski staff commented 6 years ago

Thanks for the suggestion! I added this to our ideas list


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: Yes
Tags