Bootstrap: Bootstrap 4 Beta v2 JS not working with WordPress jQuery

Created on 22 Oct 2017  路  4Comments  路  Source: twbs/bootstrap

Similar to #24417 which is closed.

When including the latest Beta v2 JS in a WordPress environment the following error is in the console: TypeError: Cannot read property 'fn' of undefined on Chrome. Safari and Firefox also fail to load, but a slightly different error.

JS Bin: https://jsbin.com/sowahazege/1/edit?html,js,console,output

I have included jQuery from a current live WP install on my server.

Swapping out the Beta V2 JS for the Beta V1 JS corrects the issue. As does loading jQuery from a CDN instead of the bundled WP version.

Has something changed between Beta v1 and v2 on how the jQuery object is accessed?

js v4

Most helpful comment

I fixed it with a litle code in functions.php:

wp_deregister_script('jquery' ); //
wp_register_script('jquery', 'http://code.jquery.com/jquery-latest.min.js',null,false,true);
wp_enqueue_script('jquery');

All 4 comments

@Johann-S: I think it's the $ change. We need to revert to jQuery which is always defined I believe.

I've been banging my head, trying to figure out what I'm doing wrong, so I'm glad someone else is experiencing this issue.

A quick fix for those who have this issue, in a script tag under jQuery script tag add : var $ = window.jQuery

I fixed it with a litle code in functions.php:

wp_deregister_script('jquery' ); //
wp_register_script('jquery', 'http://code.jquery.com/jquery-latest.min.js',null,false,true);
wp_enqueue_script('jquery');

Was this page helpful?
0 / 5 - 0 ratings

Related issues

devfrey picture devfrey  路  3Comments

bellwood picture bellwood  路  3Comments

kamov picture kamov  路  3Comments

leomao10 picture leomao10  路  3Comments

fohlsom picture fohlsom  路  3Comments