How to prevent Twitter typeahead from filling in the input with the selected value?

前端 未结 5 1595
深忆病人
深忆病人 2020-12-18 08:17

I\'m using Twitter\'s typeahead plugin for autocompletion with a text input. I want to change the behavior so that instead of putting the selected option\'s value into the t

5条回答
  •  情书的邮戳
    2020-12-18 09:01

    Same as @Nate's answer except in version (0.11.1), the event is called typeahead:close not typeahead:closed and the only parameter is the event:

    $("#input").typeahead(
        // ...
    )
    .on('typeahead:close', function (evt) {
        console.log(evt);
        $(obj.currentTarget).val("");
    });
    

提交回复
热议问题