Skip to content
Advertisement

Using MDBootstrap with Laravel?

For days I’ve been trying to use MDBootstrap with my Laravel project. I’m especially trying to create MDBootstrap Datatables. I’ve successfully installed MDB with npm and yarn but I’m getting a jquery error ReferenceError: $ at the $(document) in my web browser’s console when trying to access the index.blade.html page. This index page is being extended from the app.blade.html, which includes the scripts that Bootstrap’s webpage over MDB Data Tables requires. I downloaded MBD directly and tested out their datatables and the index.html worked flawlessly. I’m still very new to Laravel (and PHP) so any recommendations would be greatly appreciated.

app.blade.html

JavaScript

index.blade.html

JavaScript

UsersController.php

JavaScript

Advertisement

Answer

As I have painfully discovered, using MDBootstrap with Laravel can be a little finicky at times, but I got my datatable functioning properly and with the correct styling after I was able to correctly reference the required js files (using Laravel Mix). With the styling, I neglected using app.sass as at the time I was unaware of its functionality. However, there were/are some times after including other scripts when mdb.min.js will still throw me the “TypeError: “exports” is read-only” error which I resolve by deleting the js files from the public folder and recompiling.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement