Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Typeahead不';无法使用引导3_Javascript_Jquery_Typeahead.js_Twitter Typeahead - Fatal编程技术网

Javascript Typeahead不';无法使用引导3

Javascript Typeahead不';无法使用引导3,javascript,jquery,typeahead.js,twitter-typeahead,Javascript,Jquery,Typeahead.js,Twitter Typeahead,我不能让它工作。我在控制台上没有任何错误。列表根本没有出现 以下是我的html代码: <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <script type="text/javascript" src="/static/js/bootstrap.min.js"></script&

我不能让它工作。我在控制台上没有任何错误。列表根本没有出现

以下是我的html代码:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/typeahead.jquery.js"></script>


<form method="POST" class="search-form" name="search-form">
    <input id="keywords" name = "searchtext" type="text" class="search-input" placeholder="Enter your text..." autocomplete="off">
    <button type="submit" class="search-submit">Search Now</button>
</form>

<script type="text/javascript">
    $(function(){

      // applied typeahead to the text input box
      $('#keywords').typeahead({
        name: 'keywords',

        // data source
        local: ['pattern recognition', 'supervised learning', 'support vector machines'],

        // max item numbers list in the dropdown
        limit: 10
      });

    });
</script>

现在搜索
$(函数(){
//将typeahead应用于文本输入框
$(“#关键字”)。请提前键入({
名称:'关键字',
//数据源
本地:[“模式识别”、“监督学习”、“支持向量机”],
//下拉列表中的最大项数列表
限额:10
});
});

问题在于,Bootstrap3没有像2.3和更早版本那样包含一个typeahead库。您正在使用的typeahead.js库的工作方式大不相同,这里有一些关于如何使用它的好例子。

您使用的是什么版本的typeahead.js?@Dhaulagiri我从这里下载了最新版本,我认为它是0.10.2。我认为该库的工作方式与您尝试使用它的方式不同。你看了吗?嗯,我试着用我在网上找到的教程。我将尝试在我的项目中实现您链接中的一个示例。我怀疑大多数教程都过时了。该库在过去几个月刚刚更新,与以前的版本不向后兼容。您忘记包含链接了!:)修正了,很抱歉