WordPress: How to wp_enqueue_script jquery-ui / autocomplete

If you are trying to enqueue jquery’s autocomplete in wordpress, I’d suggest just using the remote version through google’s CDN / API site. You can deregister the jquery-ui with the first line of code, re-register it with the second line of code, and then activate it with the third line of code:

wp_deregister_script('jquery-ui');
wp_register_script('jquery-ui','http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js',array('jquery'));
wp_enqueue_script('jquery-ui');

You may also want to enqueue the styles using something like:

wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); 

And more recently I found this project on GitHub which has some nice examples and code that may be more updated than the version included with wordpress:

https://github.com/dyve/jquery-autocomplete

Related Posts:

  • No Related Posts
This entry was posted in Web Development and tagged , , , . Bookmark the permalink.

4 Responses to WordPress: How to wp_enqueue_script jquery-ui / autocomplete

Leave a Reply

Your email address will not be published. Required fields are marked *