Get selected items value for Bootstrap's typeahead

前端 未结 6 1856
萌比男神i
萌比男神i 2021-01-01 20:17

Bootstrap just implemented a neat autocomplete feature called typeahead. I am having trouble getting the appropriate value for the text input.

For instance, I might

6条回答
  •  孤独总比滥情好
    2021-01-01 20:32

    $('#myselector').typeahead({
    itemSelected:function(data,value,text){
       console.log(data)
        alert('value is'+value);
        alert('text is'+text);
    },
    //your other stuffs
    });
    

    You have to just pass itemSelected in the callback function and it will give you the selected item.

    Hope this will work for you.

提交回复
热议问题