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.)
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.
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.
Syntax: $("TagId"). autocomplete({ source : itemList // List of Words. })
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.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With