bootstrap typeahead阻止默认选择

时间:2013-04-30 10:19:46

标签: twitter-bootstrap preventdefault bootstrap-typeahead

我可以阻止bootstrap typeahead填充/清除元素吗?

以下是bootply.com/79110

的示例

注意我是如何使用自己的代码更新元素的。当警报出现时,您将看到它有效,但随后元素值被删除。我想阻止typeahead更新元素。

1 个答案:

答案 0 :(得分:0)

通常,updater函数返回项目..

updater: function (item) {
     /* do whatever you want with the selected item */
     return item;
},

因此,如果您没有updater函数返回该项,则不会设置输入..

updater: function (item) {
     /* do whatever you want with the selected item */
    alert("selected "+item);
},

Demo on Bootply