Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get jQuery autocompletion in TypeScript?

If I'm working in a TypeScript .ts file, what can I do to get jQuery Intellisense/autocompletion when I type the $ character?

(I'm working in an ASP.NET MVC 3 project in VS 2012.)

like image 469
Ryan Lundy Avatar asked Oct 01 '12 22:10

Ryan Lundy


People also ask

How to use jQuery Autocomplete?

Auto completion is a mechanism frequently used in modern websites to provide the user with a list of suggestions for the beginning of the word, which he/she has typed in a text box. The user can then select an item from the list, which will be displayed in the input field.

How to use jQuery Autocomplete with Ajax?

Autocomplete feature is used to provide the auto suggestion for users while entering input. In this tutorial, we are going to suggest country names for the users based on the keyword they entered into the input field by using jQuery AJAX. jQuery Autocomplete function is called on the key-up event of the input field.

How can create autocomplete search box in jQuery?

Syntax: $("TagId"). autocomplete({ source : itemList // List of Words. })

What is JavaScript autocomplete?

The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try. The datasource is a simple JavaScript array, provided to the widget using the source-option.


2 Answers

You need to add a reference to the jQuery definition at the top of your .ts file.

/// <reference path="jquery.d.ts" /> 

You can find type annotations for jQuery in this sample.

like image 180
mohamed hegazy Avatar answered Sep 17 '22 09:09

mohamed hegazy


Check out these type definitions for TypeScript: https://github.com/borisyankov/DefinitelyTyped#readme. They're being updated regularly and are more complete than the ones in the examples. On Nuget: http://www.nuget.org/profiles/DefinitelyTyped/

like image 41
jvitor83 Avatar answered Sep 17 '22 09:09

jvitor83