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 in JQuery by Rahul
• 8,980 points
19 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 by Aditya
• 7,280 points

Related Questions In JQuery

0 votes
1 answer

How to check if a jQuery plugin is loaded?

Hello @kartik, for the plugins that doesn't use ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,680 points
653 views
0 votes
1 answer

Uncaught ReferenceError:Karma: jQuery is not defined

Hii @kartik, You first have to load jQuery ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,680 points
2,721 views
0 votes
1 answer

Error:jquery each loop return false not end the function

Hii @kartik, Returning from one function doesn't call as it's ...READ MORE

answered Jun 2, 2020 in JQuery by Niroj
• 82,680 points
3,663 views
0 votes
1 answer

How can selector expression to not select elements with a specific class?

Hello @kartik, You need the :not() selector: $('div[cla ...READ MORE

answered Nov 26, 2020 in JQuery by Niroj
• 82,680 points
146 views
0 votes
1 answer

How can I implement my own $(document).ready functionality without using jQuery?

Hello @kartik,  There are three options: If script is the last ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,680 points
610 views
0 votes
1 answer

How to use jquery with asp.net ajax?

If you weren't aware, Microsoft is planning ...READ MORE

answered Oct 15, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
161 views
0 votes
1 answer

Is 'sparkline' a method?

I suggest you to check 2 things That jquery.sparkline.js is actually ...READ MORE

answered Nov 9, 2018 in Apache Spark by Frankie
• 9,830 points
549 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,510 points
281 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19, 2020 in PHP by Niroj
• 82,680 points
249 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 in JQuery by Aditya
• 7,280 points
33 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP