I just created a search function using the typeahead jquery library. My problem is that when i select an item from the dropdown list it return all the synonyms inside the input field instead of the name of item:
In my example if you try to type "Fruits" and select the item from the drop-down list it works ok. But if you try to type "Apple" or "Orange" and then select "Fruits" from the drop-down list, then it returns all the synonyms of "Fruits" in the input field eg "Apple, Orange, Banana".
I just want to get only the name of the item inside the input field when i select an item from the list no matter if i type the name itself or its synonyms. What am i doing wrong?
Here is my JSFIDDLE