From 735c0f1d5d58cff9399035d4f70d6d30a12256c7 Mon Sep 17 00:00:00 2001 From: Basarat Syed Date: Mon, 21 Jul 2014 11:48:03 +1000 Subject: [PATCH] Added val methods - ref https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md#api --- typeahead/typeahead-tests.ts | 5 +++++ typeahead/typeahead.d.ts | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 67fc8d31a3a7fc..1044fe3bff08bd 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -85,3 +85,8 @@ $('.example-countries .typeahead').typeahead({ prefetch: '../data/countries.json', limit: 10 }); + +module valueTest { + var value: string = $('foo').typeahead('val'); + $('foo').typeahead('val', value); +} \ No newline at end of file diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index f6f387986ba7a7..bb8aaf31dce5c0 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -60,6 +60,17 @@ interface JQuery { * @param dataset Array of datasets */ typeahead(options: Twitter.Typeahead.Options, dataset: Twitter.Typeahead.Dataset): JQuery; + + /** + * Returns the current value of the typeahead. The value is the text the user has entered into the input element. + */ + typeahead(methodName: 'val'): string; + typeahead(methodName: string): string; + + /** + * Sets the value of the typeahead. This should be used in place of jQuery#val. + */ + typeahead(methodName: 'val', value: string): JQuery; } declare module Twitter.Typeahead {