I've been looking for ways to make an enqueue of the right library of jquery ui but i dont see there is one for that, any ideas of how to use this without getting error?
jQuery('#menu_desktop').toggle("slide", {direction: "left"});
/
My jquery ui enqueue
wp_enqueue_script('jquery-ui', '.12.1/jquery-ui.min.js', '1', true);
wp_enqueue_script('menu_script', get_stylesheet_directory_uri() . '/js/menu.js', array('jquery', 'jquery-ui'), '1', true);
My error
jquery.min.js?ver=3.4.1:2 Uncaught TypeError: k.easing[this.easing] is not a function
at init.run (jquery.min.js?ver=3.4.1:2)
at u (jquery.min.js?ver=3.4.1:2)
at Function.k.fx.tick (jquery.min.js?ver=3.4.1:2)
at lt (jquery.min.js?ver=3.4.1:2)
Libraries are being imported
I've been looking for ways to make an enqueue of the right library of jquery ui but i dont see there is one for that, any ideas of how to use this without getting error?
jQuery('#menu_desktop').toggle("slide", {direction: "left"});
https://developer.wordpress/reference/functions/wp_enqueue_script/
My jquery ui enqueue
wp_enqueue_script('jquery-ui', 'http://ajax.googleapis/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', '1', true);
wp_enqueue_script('menu_script', get_stylesheet_directory_uri() . '/js/menu.js', array('jquery', 'jquery-ui'), '1', true);
My error
jquery.min.js?ver=3.4.1:2 Uncaught TypeError: k.easing[this.easing] is not a function
at init.run (jquery.min.js?ver=3.4.1:2)
at u (jquery.min.js?ver=3.4.1:2)
at Function.k.fx.tick (jquery.min.js?ver=3.4.1:2)
at lt (jquery.min.js?ver=3.4.1:2)
Libraries are being imported
Share Improve this question edited Jan 22, 2020 at 1:16 Christian asked Jan 22, 2020 at 0:52 ChristianChristian 1011 bronze badge 4- Can you show us how you're attempting to enqueue the script - the link you provided has the correct info (jQuery UI Core is the one you want)... ...so not sure what the error you're getting is. – Tony Djukic Commented Jan 22, 2020 at 1:10
- @TonyDjukic hi tony i just updated the post – Christian Commented Jan 22, 2020 at 1:16
- The error is basically telling you that the easing function isn't available. Instead of .toggle() can you try .slideToggle(). Do you have a URL you can share? – Tony Djukic Commented Jan 22, 2020 at 4:40
- 1 @TonyDjukic it works but without the direction argument which i dont need :c – Christian Commented Jan 22, 2020 at 13:17
1 Answer
Reset to default 0As jQuery UI is included in the Wordpress Core, you don't need to load it from the CDN. Please try to change your wp_enqueue_scripts from
wp_enqueue_script('jquery-ui', 'http://ajax.googleapis/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', '1', true);
wp_enqueue_script('menu_script', get_stylesheet_directory_uri() . '/js/menu.js', array('jquery', 'jquery-ui'), '1', true);
to
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-effects-slide');
wp_enqueue_script('menu_script', get_stylesheet_directory_uri() . '/js/menu.js', array('jquery', 'jquery-ui-core','jquery-effects-slide'), '1', true);
Also be sure to call for the Slide Effect within a document.ready function ;)