0

I have tried below script to load jQuery UI Autocomplete in theme. But it doesn't load their related scripts. How should I call it to work.

wp_enqueue_script('jquery-ui-autocomplete');

I think below scripts are jQuery UI related scripts for autocomplete but it's doesn't load.

<script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.position.min.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.menu.min.js?ver=1.10.2'></script>
<script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js?ver=1.10.2'></script>
0

Try to load the script in the footer section.

<script type="text/javascript"
        src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript"
        src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript">
                $(document).ready(function(){
                    $("#clientAutocomplete").autocomplete({
                        source:'client_autocomplete.php',
                        minLength:1
                    });
                });
        </script>

This worked for me

  • I think it isn't WP prefer method but jquery-ui.min.js was loaded. Unfortunately still trouble to use autocomplete combobox feature. Anyway thanks for your help @1991wp – pico Dec 31 '15 at 6:42
  • According to the demo _create: function() { didn't work so no more input to work as demo. – pico Dec 31 '15 at 7:38
0

As for the stylesheets: WordPress does not register jQuery UI styles by default!

You have to include the theme you want by calling wp_enqueue_style(). Since you need the right version, you can call wp_scripts() and check for the registered jQuery UI core version.

See details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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