Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: body is null #31

Closed
ipepe opened this issue Nov 23, 2016 · 3 comments
Closed

TypeError: body is null #31

ipepe opened this issue Nov 23, 2016 · 3 comments

Comments

@ipepe
Copy link

ipepe commented Nov 23, 2016

I included mdb.js in head and Im getting

TypeError: body is null

Code:

   Waves.init = function (options) {
        var body = document.body;

        options = options || {};

        if ('duration' in options) {
            Effect.duration = options.duration;
        }

        if ('delay' in options) {
            Effect.delay = options.delay;
        }

        if (isTouchAvailable) {
            body.addEventListener('touchstart', showEffect, false);
            body.addEventListener('touchcancel', TouchHandler.registerEvent, false);
            body.addEventListener('touchend', TouchHandler.registerEvent, false);
        }

        body.addEventListener('mousedown', showEffect, false); //TypeError: body is null
    };

Error is marked on last line

@marktopper
Copy link

I think it should be added to the end of the body tag.

@mdbootstrap
Copy link
Collaborator

Dear ipepe, you are including js in head, due to that when website JS and try to assign body to the variable it cannot do this because this elements wasn't crated yeat (body tag is below head). You have to place your script below body.

@ipepe
Copy link
Author

ipepe commented Nov 28, 2016

Lol, I know what happend. I just assumed that placing script src tags in head is something normal in modern web development. I guess I will have to patch it myself.

aruprakshit referenced this issue in LizBayardelle/TOCACares Aug 10, 2019
MDB issue source https://github.com/mdbootstrap/bootstrap-material-design/issues/31

mdb js doesn't get loaded well from head tag, but body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants