2013-05-08 36 views
2

我跟着this tutorial,並推出了一個ajax源文件(django後端)的twitter typeahead,用於推薦到我的下拉框中。twitter的typeahead與標題的建議,如何?

我可以讓我的下拉給我根據我從進入,但我希望能有頭組織的各種建議,如在這個例子中建議:

enter image description here

從這個網站:http://twitter.github.io/typeahead.js/examples/

這些網站上的例子的問題是他們不使用ajax源。我試圖修改預輸入呼叫這樣

$(".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數據源用做標題標籤這樣的自動建議不同類型的建議?

回答

0

從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尚未包含此功能。

你可以定製你的引導js文件(這裏:http://twitter.github.io/bootstrap/customize.html)排除引導的最新預輸入插件,然後包括更先進的JavaScript在http://twitter.github.io/typeahead.js/releases/latest/typeahead.js,這樣就可以用它來代替。

希望這會有所幫助!

+0

好吧,看起來Bootstrap實際上是在他們的下一個版本中完全放棄他們的typeahead,而是單獨使用高級的twitter typeahead腳本。檢查它:https://twitter.com/twbootstrap/status/332334721029791745 – georgedyer 2013-05-09 13:33:54