0

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.org/reference/functions/wp_enqueue_script/

My jquery ui enqueue

wp_enqueue_script('jquery-ui', 'http://ajax.googleapis.com/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

enter image description here

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. Jan 22, 2020 at 1:10
  • @TonyDjukic hi tony i just updated the post
    – Christian
    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? Jan 22, 2020 at 4:40
  • 1
    @TonyDjukic it works but without the direction argument which i dont need :c
    – Christian
    Jan 22, 2020 at 13:17

1 Answer 1

0

As 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.com/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 ;)

2
  • It does not work :c still getting the same error
    – Christian
    Jan 22, 2020 at 13:18
  • Can you try changing your jquery-code to this: jQuery('#menu_desktop').toggle("slide", {direction: "left", easing:'linear'}); ? Jan 22, 2020 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.