I ran into this seemingly innocuous error in my MVC4 app:
Uncaught TypeError: Object [object Object] has no method 'autocomplete'
Googling mostly resulted in “you have multiple versions of jQuery referenced,” which was not my case.
How did I fix this?
- Update jQuery: I had 1.7.1 running on my site. Auto-complete requires 1.8 or higher. Right-click on the solution, “Manage NuGet Packages …”, “Updates”, and update both jQuery and jQuery UI.
- Use jQuery UI: Although I had the scripts specified in a bundle called
jqueryui
, they’re not rendered. So I added this line under the jQuery bundle rendering in_Layout.cshtml
:@Scripts.Render("~/bundles/jqueryui")
- Render the jQuery UI CSS: jQuery UI requires some CSS files to be included. They were bundled, but not rendered; so I rendered them by adding
@Styles.Render("~/Content/themes/base/css")
to my layout.
And that’s it! You’ll have to check that these bundles exist for you (see BundleConfig.cs
) and have the required files included.