ASP.NET MVC 4: Uncaught TypeError: Object [object Object] has no method ‘autocomplete’

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.

About Ashiq Alibhai, PMP

Ashiq has been coding C# since 2005. A desktop, web, and RIA application developer, he's touched ASP.NET MVC, ActiveRecord, Silverlight, NUnit, and all kinds of exciting .NET technologies. He started C# City in order to accelerate his .NET learning.
This entry was posted in Libraries, Web and tagged . Bookmark the permalink.

One Response to ASP.NET MVC 4: Uncaught TypeError: Object [object Object] has no method ‘autocomplete’

  1. Damian says:

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *