TypeError autocomplete is not a function

0 votes

I am getting the TypeError: $(...).autocomplete is not a function when using the following code inside a Drupal module.

jQuery(document).ready(function($) { 
              $("#search_text").autocomplete({ 
                    source:results, 
                    minLength:2, 
                    position: { offset:'-30 0' }, 
                    select: function(event, ui ) { 
                                  goTo(ui.item.value); 
                                  return false; 
                } 
      }); 
});

jQuery should work and I have tried using a different variable for $ - any ideas what else might be the problem?


Drupal specific answer for autocomplete:

drupal_add_library('system', 'ui.autocomplete');

Feb 23, 2022 in JQuery by Rahul
• 9,680 points
9,599 views

1 answer to this question.

0 votes

You would definitely have missed the Jquery UI Library. Use CDN of Jquery UI or if you want it locally then download the file from Jquery UI as mentioned below:-

<link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" rel="Stylesheet"> <script src="YourJquery source path"></script> 
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>

answered Feb 23, 2022 by Aditya
• 7,680 points

Related Questions In JQuery

0 votes
1 answer

jQuery fix for "Uncaught TypeError: $ is not a function" error

We can fix this error by using jQuery() . ...READ MORE

answered Jun 1, 2022 in JQuery by Edureka
• 13,690 points
5,852 views
0 votes
1 answer

Jquery validation plugin - TypeError: $(...).validate is not a function

The "$(...). validate is not a function" ...READ MORE

answered Jun 28, 2022 in JQuery by rajatha
• 7,680 points
16,563 views
0 votes
1 answer

jQuery UI " $("#datepicker").datepicker is not a function"

The "$(...).datepicker is not a function" jQuery ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,690 points
15,278 views
0 votes
1 answer

$ is not a function - jQuery error

The typeerror: $ is not a function ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,690 points
1,293 views
0 votes
1 answer
0 votes
0 answers

jQuery UI DatePicker - Change Date Format

I am using the UI DatePicker from ...READ MORE

Jun 23, 2022 in Web Development by gaurav
• 23,260 points
1,023 views
0 votes
1 answer

jQuery dialog popup

This HTML is fine: <a href="#" id="contactUs">Contact Us</a> ...READ MORE

answered Jun 28, 2022 in Web Development by rajatha
• 7,680 points
1,138 views
0 votes
1 answer

Date range picker on jquery ui datepicker

Thanks I need this kind of code. ...READ MORE

answered Jun 27, 2022 in Web Development by rajatha
• 7,680 points
4,931 views
0 votes
1 answer

Loading gif in jQuery ajax call is not showing

Create a div with your image. Make it ...READ MORE

answered Jun 27, 2022 in Web Development by rajatha
• 7,680 points
1,714 views
0 votes
1 answer

Difference between $(window).load() and $(document).ready() functions

To answer your question, the document.ready is ...READ MORE

answered Feb 23, 2022 in JQuery by Aditya
• 7,680 points
1,677 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP