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

Allow to put mdb.js to header #49

Closed
ostrolucky opened this issue Mar 7, 2017 · 13 comments
Closed

Allow to put mdb.js to header #49

ostrolucky opened this issue Mar 7, 2017 · 13 comments
Labels

Comments

@ostrolucky
Copy link

We have lot of inline javascripts generated via backend. If these scripts use mdb functions, they will crash, because mdb.js requires to include it at the end of HTML body.

Only way I see to make this currently work is to wrap all of the inline scripts to some function, which sucks.

@mattonit
Copy link
Contributor

mattonit commented Mar 7, 2017

Do you load MDB.js after jQuery and Bootstrap?

@ostrolucky
Copy link
Author

Yes. Problem is definitely mdb.js.

@mattonit
Copy link
Contributor

mattonit commented Mar 8, 2017

do you get any console logs?

@ostrolucky
Copy link
Author

TypeError: body is null

@ipepe
Copy link

ipepe commented Mar 9, 2017

@gadelat I tried convincing them at #31 , not luck. I use this to fix it:

(function ($) {
    $(document).ready(function () {
        //Initialization
        Waves.attach('.btn, .btn-floating', ['waves-light']);
        Waves.attach('.waves-light', ['waves-light']);
        Waves.attach('.navbar-nav a:not(.navbar-brand), .nav-icons li a, .navbar form, .nav-tabs .nav-item', ['waves-light']);
        Waves.attach('.pager li a', ['waves-light']);
        Waves.attach('.pagination .page-item .page-link', ['waves-effect']);
        Waves.init();/* FORMS */
    });
});

@blimey85
Copy link

I have the Pro version and I'm using it with a Rails app, which uses TurboLinks, which requires all JS files to be included in the head. @ipepe's work around didn't work for me but I managed to split out MDB from the standard manifest and load it in the body. The problem I'll run into is that TurboLinks is going to replace the body of the page, and MDB should already be loaded rather than it loading again and again. It will be cached of course, but that's still a lot of overhead.

Is it not possible for MDB to be updated to solve this problem? Is there a feature or file I can drop that will resolve this? It looks to just be the Waves feature?

@agavazov
Copy link

Please wrap Waves.initialization into $(document).ready(function () { ... initialization here .... }); as @ipepe told you.

@mattonit
Copy link
Contributor

I marked this as a bug and added to our TODO list

@vipantonio
Copy link

Please wrap Waves.initialization into $(document).ready(function () { ... initialization here .... }); as @ipepe told you.

I think it should be wrapped into:

$( document ).on('turbolinks:load', function() { ... initialization here .... });

@muzbox
Copy link

muzbox commented Mar 19, 2019

I marked this as a bug and added to our TODO list

Was this ever actioned? I am having the same issue with turbo links and waves

@carltonsmith
Copy link

having the same issue here

@locddspkt
Copy link

I have the same issue. This is what I should do:
Include all the css, js script but mdb.js. And then, put it at the bottom before the end body tag

@PiotrObrebski
Copy link
Contributor

We decided that it can be done. Waves.js will be launched after the document is ready. It should be in the next released package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants