s

jquery error autocomplete is not a function edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 21 September 2020 | 2464

while I was trying to use jquery ui autocomplete in my application I got this error jquery autocomplete is not a function error

Solution

the first thing to do is to make sure that jquery, jquery-UI is added to the HTML

    <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">

Also make sure that jquery-ui is added after jquery has been added. In my asp .net application, I was adding jquery-ui.js to the bottom of the view. The problem with this was jquery UI gets added after jquery. For me, the solution was to open _Layout.cshtml and add jquery-ui.js & jquery-ui.css after @RenderSection("scripts", required: false). Also I moved all the script to the top to the <head> element