使bootstrap typeahead自动完成可点击

时间:2013-08-05 19:11:06

标签: twitter-bootstrap autosuggest clickable typeahead

我使用的是Bootstrap Typeahead,我是从GitHub 1891669获得的。它提出了建议的字样,但想解决两个问题:

The example is here

  • 当我点击该项目时,它只在文本字段中打印0。我该怎么做才能打印完整的单词?
  • 如何使用建议字词对每个建议进行点击?

我查看了代码。 Typeahead javascript具有以下内容:

      $.fn.typeahead.defaults = {
     source: []
     , items: 8
     , menu: '<ul class="typeahead dropdown-menu"></ul>'
     , item: '<li><a href="#"></a></li>'
     , onselect: null
     , property: 'value'
     }

所以我想href="mylink.php?term=**theword**" 那么如何在上面的href中插入建议的单词代替 theword ,这样当用户点击链接时,它就不会填充文本字段,而是转到带有参数的mylink.php

在该示例中,我已经使用bootstrap.js插入了Typeahead javascript。为了便于您查看Typeahead java脚本here

感谢

1 个答案:

答案 0 :(得分:0)

您使用的是旧版本的Typehead(v2.0.0),该版本已更新以修复该问题。请尝试使用最新版本:http://twitter.github.io/typeahead.js/examples/