bootstrap 3 typeahead不会显示结果

时间:2013-10-29 16:39:37

标签: asp.net-mvc-4 twitter-bootstrap

我试图在mvc 4中实现typeahead。

(我包括了typeahead js和css。)

我使用这个ajax方法来获取列表

$(function() {
         // get your list
         $.getJSON('/Main/GetServiceNames', function (allData) {
             $('#servicename').typeahead({source: allData});
         });
     });

这是ajax请求的结果:

["RetrieveDocument","PublishDocument","PublishFeedback","PublishSurvey","RetrievePartner","RetrieveLabelDocuments","RPCRetrieveZipCode","ESB2InfraService","PublishTest","PublishPolcy"]

但由于某种原因,结果不会绑定到 #servicename Html输入
这是我试图绑定的html,并且没有显示列表。

     <input type="text" class="form-control" placeholder="servicename" id="servicename" data-provide="typeahead"> 

编辑: 我设法在typeahead fiddel

创建了相同的错误

感谢

三木

1 个答案:

答案 0 :(得分:0)

看一下示例here。另外,请记住 Bootstra的typeahead.js Twitter的typeahead.js 不同,我认为您正在使用它。你可以得到Bootstrap的typeahead.js here