2016-08-23 29 views
2

typeaheadのオプション数を増やすにはどうすればよいですか?以下はTypeahead.jsには5つのオプションしか表示されません

私のコードです:

var substringMatcher = function (strs) { 
    return function findMatches(q, cb) { 
     var matches, substringRegex; 

     // an array that will be populated with substring matches 
     matches = []; 

     // regex used to determine if a string contains the substring `q` 
     substrRegex = new RegExp(q, 'i'); 

     // iterate through the pool of strings and for any string that 
     // contains the substring `q`, add it to the `matches` array 
     $.each(strs, function (i, str) { 
      if (substrRegex.test(str)) { 
       matches.push(str); 
      } 
     }); 

     cb(matches); 
    }; 
}; 

$(function() { 
    $.get('@Url.Action("getApplications")',function (data) { 
     //console.log(data); 
     $('#the-basics #Appl_ShortName_textbox').typeahead(
     { 
      hint: false, 
      highlight: false, 
      minLength: 1, 
      minLimit: 10, 
      maxLimit: 10 
     }, 
    { 
     name: 'data', 
     source: substringMatcher(data) 
    }); 
    }); 
}); 

答えて

0

"ソース:substringMatcher(データ)" の "制限を:(あなたが表示する項目の最大#を好き)" を追加します。例えば

source: substringMatcher(data), 
limit: 20 

は最大20の項目とドロップダウンメニューになります。

関連する問題