0
手頭的問題是,搜索建議不被同一起跑線字符排列如可以在圖片中可以看出:'ne' should be at the very top, yet it is at the very bottomTwitter的建議事先鍵入的內容訂貨
我怎樣才能解決這個問題呢?
以下是我code` $(文件)。就緒(函數(){ // VAR的查詢=銀行;
var queries = ['there is no need', 'need', 'no need', 'ne'];
//Dataset defined in index.php
// *****
//(NOTE: Typehead works by the order of the elements in dataset, thus
// they are ordered in the database first based on count)
//Constructing the suggestion engine
var queries = new Bloodhound(
{
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: queries
});
// Initializing the typeahead (.typehead is the selector having what's currently
// being typed)
$('.typeahead').typeahead(
{
hint: true,
highlight: true, /* Enable substring highlighting */
minLength: 1 /* Specify minimum characters required for showing result */
},
{
name: 'queries',
source: queries
});
}); `