admin管理员组文章数量:1122846
Our site has been getting these recurring errors which I cannot track down and just needed some guidance. Each error revolves around jQuery and Bootstrap 4.6 methods as not a function. Here's what I've done so far:
- Made sure jQuery is loaded first and all other scripts are dependent on jQuery
- Made sure all of our jQuery-dependent scripts are loaded in the footer (our site loads jQuery in the header...is this correct?)
- Tried calling methods in the following ways:
// One
jQuery('#example-modal').modal('show');
//Two
$('#example-modal').modal('show');
// Three
jQuery(($) => { $('#example-modal').modal('show') });
Here is how we're loading the scripts:
// Popper
wp_enqueue_script( 'popper-js', get_template_directory_uri() . '/assets/js/popper.min.js', array( 'jquery' ), $version, true );
// Bootstrap (in footer??)
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array( 'jquery', 'popper-js' ), $version, true );
// Theme
wp_enqueue_script( 'theme-js', get_template_directory_uri() . '/assets/js/theme.bundled.js', array( 'jquery', 'bootstrap-js' ), $version, true );
These methods work for me all the time on a mac with FireFox, but I'm still getting them in Sentry. I've noticed the vast majority (96%) is on Windows >= 10.
Here are some some links to the error:
Error 1 Error 2 Error 3
For more context, I write JS in almost exclusively vanilla JS until I need a Bootstrap method. Am I missing something? This is driving me a little crazy.
本文标签: scriptsmodal()tabtooltip is not a function jQuery
版权声明:本文标题:scripts - .modal(), .tab, .tooltip is not a function jQuery 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302333a1931492.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论