2017-06-06 83 views
0

我正在使用bootstrap3 typeahead,但我有一些情況,當我的API返回很多結果(約40),但鍵入彈出窗口8結果。Bootstrap3 typeahead limit

我試圖解決這個使用

limit: 30 

,但沒有奏效。

如何將其更改爲僅顯示8個結果?

順便說一句,我的預輸入是

$('#postcode').typeahead({ 
    source: function (query, process) { 
    var ajaxResponse; 
    $.ajax({ 
     url: "my_url", 
     type: "GET", 
     cache: false, 
     success : function (response) { 
     process(response.addresses); 
     } 
    }); 
    }, 
    limit: 30, 
    minLength: 2, 
    displayText: function(item) { 
    return item.full_description; 
    }, 
    updater: function(item) { 
    // some func here 
    return item; 
    } 
}); 

回答

-1

這不是「限制」,你所尋找的,而是「項」。改變它,它會起作用。

您可以給出特定數量的項目,或者只指定「全部」。

+1

您可能希望通過顯示更正的代碼來改善您的答案。官方文件的鏈接也有助於支持您的聲明。 –