Input typeahead throwing : typeahead is not a function

147
May 19, 2017, at 7:04 PM

I am working with Angular JS application, in which we have input field as typeahead. It working fine, below is code of creating input field :

Input Typeahead :

<input
placeholder="{{myName}}"
class="form-control" id="field_name"
name="myName" type="text"
ng-model="myModel"
uib-typeahead="r as r.myName for r in vm.list | filter:{myName:$viewValue} | limitTo:25"
autocomplete="off" typeahead-editable="false" class="form-control">

I need to set some value manually to this input typeahead field. I tried val(), text() on it, but these are not working. Then I tried following :

$('#field_name').typeahead('val',"My Value");

Its setting value but throwing exception : TypeError: $(...).typeahead is not a function

Also have tried angular.element($("#field_name")).triggerHandler('change'); but it does not making any change.

How can I set value to typeahead input field manually.

Answer 1

if you see the error message "TypeError: $(…).typeahead is not a function" it mean typeahead function is not provided in the version of bootstrap you are using. Officially the typeahead is dropped from the new release 3.0. And is available separtely in typeahead.js.

you need to include the the typeahead.js plugin the error will remove.

READ ALSO
How to add div to text within dynamic nested div using jquery

How to add div to text within dynamic nested div using jquery

Below is the HTML format code for the nested div

68
Ember component multiple ajax calls

Ember component multiple ajax calls

I am very new to ember js 213

114
How to open new form on dynamic button click event in php

How to open new form on dynamic button click event in php

I have created dynamic button in phpi need to to open new form in same homepage on that dyanamic button click event and when i am clicking on button it refresh the page

94
ASP MVC Refresh partial view grid

ASP MVC Refresh partial view grid

I am trying to refresh a partial view grid after changing a recordI have a button where the user can click on, than it will change a row in the grid

78