【问题标题】:twitter typeahead with headers for the suggestions, how?twitter 预先输入带有标题的建议,如何?
【发布时间】:2013-05-08 17:07:00
【问题描述】:

我关注this tutorial 并使用 ajax 源(django 后端)实现了 twitter typeahead,以便在我的下拉框中提供建议。

我可以让我的下拉列表根据我输入的内容给我建议,但我希望能够有标题来组织各种建议,例如在这个例子中:

来自这个网站:http://twitter.github.io/typeahead.js/examples/

这些站点上的示例的问题是它们都没有使用 ajax 源。我尝试像这样修改 typeahead 调用

$(".typeahead").typeahead({
    source: function ( query, process ) {//ajax call stuff here...},
    updater: function(item) {//stuff goes here...},
    header: '<h3>Header Should Be Here</h3>', //<-- This should add a header to my suggestions, no?
    }

但我的建议列表没有标题..

是否有可能通过带有不同类型建议的标题标签的 ajax 数据源完成此类自动推荐?

【问题讨论】:

    标签: javascript jquery autocomplete bootstrap-typeahead


    【解决方案1】:

    查看 Bootstrap 项目中的 typeahead javascript 源代码,它似乎没有实现“header”选项。

    显然,http://twitter.github.io/typeahead.js/examples/ 演示的版本确实实现了标头。但它是在 3 月 24 日添加的(参见 https://github.com/twitter/typeahead.js/blob/master/CHANGELOG.md#090-march-24-2013),所以最新的 Bootstrap 还没有加入这个功能。

    您可以自定义您的 bootstrap js 文件(此处:http://twitter.github.io/bootstrap/customize.html)以排除 bootstrap 的最新 typeahead 插件,然后在 http://twitter.github.io/typeahead.js/releases/latest/typeahead.js 包含更高级的 javascript,以便您可以使用它。

    希望这会有所帮助!

    【讨论】:

    猜你喜欢
    • 2020-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 2015-02-26
    相关资源
    最近更新 更多