Topic: Uncaught TypeError: $ is not a function at mdb.min.js?ver=4.3.1:4

Abdallah Sabri free asked 7 years ago


I'm using Material Design for Bootstrap to style new Wordpress theme. I enqueued the scripts as normal, all the scripts are loaded perfectly, but I got this error in the console. Uncaught TypeError: $ is not a function at mdb.min.js?ver=4.3.1:4 I enqueue the javascript files using the following code:

        wp_enqueue_script('jquery');// My wordpress version is 4.7.2
        wp_enqueue_script('bootstrap-script', get_template_directory_uri() . '/scripts/js/vendor/bootstrap.min.js', array(), '3.3.7', true);
        wp_enqueue_script('mdb-script', get_template_directory_uri() . '/scripts/js/mdb.min.js', array(), '4.3.1', true);
        wp_enqueue_script('main-script', get_template_directory_uri() . '/scripts/js/main.js', array(), false, true);


Abdallah Sabri free answered 7 years ago


I solved it by changing this line wp_enqueue_script('mdb-script', get_template_directory_uri() . '/scripts/js/mdb.min.js', array(), '4.3.1', true); to this line wp_enqueue_script('mdb-script', get_template_directory_uri() . '/scripts/js/compiled.min.js', array(), '4.3.1', true);

Abdallah, could you please provide us more details?

Ozcan Arslan pro answered 7 years ago


Hi, please check your custom js file etc: main.js. I got the same error with Laravel 5, there was something with custom js file named app.js created by Laravel itself. I solution was removing app.js file since i didn't need it actually.

Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Specification of the issue

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