Get selected items value for Bootstrap's typeahead

前端 未结 6 1858
萌比男神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:30

    $('#autocomplete').on('typeahead:selected', function (e, datum) {
        console.log(datum);
    });
    $('#autocomplete').on('typeahead:cursorchanged', function (e, datum) {
        console.log(datum);
    });
    

    Seems Typeahead changed listeners and usages are not well documented. You can use these listeners.

    UPDATE

    Event name was changed to typeahead:select in later versions.

提交回复
热议问题