Twitter typeahead js doesnt work in asp net core mvc project


ASP.NET is a popular programming language used for building web applications. It provides a framework for developing websites, web services, and web applications. One common issue that developers face is integrating third-party libraries or plugins into their ASP.NET projects. In this article, we will discuss how to solve the of Twitter typeahead.js not working in an ASP.NET Core MVC .

Problem Description

The Twitter typeahead.js library is a powerful tool for autocomplete functionality to text input fields. However, when trying to use it in an ASP.NET Core MVC project, you may encounter where the library does not work as expected. This can be frustrating, especially if you have followed the and implemented the necessary code correctly.


To solve the problem of Twitter typeahead.js not working in an ASP.NET Core MVC project, follow these steps:

Step 1: Include the necessary dependencies

Before using the Twitter typeahead.js library, make sure you have included all the necessary dependencies. These include jQuery and the typeahead.js library itself. You can include them by adding the following code to the head section of your HTML file:

<script src=""></script>
<script src=""></script>

Step 2: Initialize the typeahead.js plugin

including the necessary dependencies, you need to initialize the typeahead.js plugin on the desired input field. This can be done by adding the following code to your JavaScript file:

$(document).ready(function() {
    var countries = new Bloodhound({
        datumTokenizer: Bloodhound.tokenizers.whitespace,
        queryTokenizer: Bloodhound.tokenizers.whitespace,
        prefetch: '/path/to/countries.json'

        hint: true,
        highlight: true,
        minLength: 1
    }, {
        name: 'countries',
        source: countries

In the above code, we are initializing the typeahead.js plugin on an input field with the ID “inputField”. We are also using the Bloodhound engine to handle the data source for the autocomplete . Make sure to replace “/path/to/countries.json” with the actual path to your JSON file the autocomplete data.

Step 3: the implementation

After following the above steps, save your changes and run your ASP.NET Core MVC project. Test the autocomplete functionality on the input field where you have applied the typeahead.js plugin. If everything is implemented correctly, you should see the autocomplete suggestions appearing as you type.


In this article, we discussed how to solve the problem of Twitter typeahead.js not working in an ASP.NET Core MVC project. By including the necessary dependencies, initializing the typeahead.js plugin, and verifying the implementation, you can successfully integrate the autocomplete functionality into your ASP.NET project. Remember to follow the documentation and ensure that your code is correctly implemented to avoid any issues.

Rate this post

Leave a Reply

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

Table of Contents