2013-04-30 46 views
4

我可以阻止引导程序typeahead填充/清除元素吗?bootstrap typehead防止默认选择

下面是一个例子bootply.com/79110

注意我是如何更新与自己的代码的元素。当警报出现时,你会看到它的工作原理,但是然后元素值被删除。我想防止更新元素。

+1

您能否提供演示? http://twitter.github.io/bootstrap/javascript.html#typeahead和http://jqueryui.com/autocomplete/似乎行为类似 – Neil 2013-06-21 01:39:15

+0

是的,演示请。如果没有一些例子或进一步的解释,以下是难以理解的:'...用项目填充输入?' – 2013-06-27 22:15:05

+0

嗨@尼尔我已经添加了演示并澄清了我的问题。请帮助:) – 2013-10-28 17:41:16

回答

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

+0

嗨Skelly, 谢谢你的例子。我分叉它来更新与该项目的输入,但它不起作用http://www.bootply.com/79110 – 2013-09-05 11:02:11