Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Andrew Folts
Andrew Folts
14,238 Points

I enqueued JQuery UI in Wordpress, but it's not working in functions.js?

When I try and use JQuery UI for something simple like linear easing of an animation, I get an error that says "linear is not defined".

Jon Goodey
Jon Goodey
33,092 Points

This should be enqueued in the functions.php file not functions.js is this a typo?

Andrew Folts
Andrew Folts
14,238 Points

I meant that I enqueued it in functions.php.

But what I try to use it in a anywhere on my site, for example in functions.js as linear easing on an animation, I get the the undefined error.

"linear is undefined".

Andrew Folts
Andrew Folts
14,238 Points

I enqueued plain jQuery and that works fine, FWI.

2 Answers

Ludvík Matějíček
Ludvík Matějíček
12,557 Points

I don't know your code in function.php file but if you enqueued scripts which are dependent on jQuery you need add dependency.

example:

wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', array( 'jquery' ) ); // add array( 'jquery' )
Andrew Folts
Andrew Folts
14,238 Points

Oh, that's what I was doing wrong. Thanks, very much appreciate the help!