将显示输入框,但“提前输入”功能无法工作。它使用最新的jquery和typeahead.bundle.min.js库。
<!doctype html>
<html lang="en">
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="typeahead.bundle.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.typeahead').typeahead({
name: 'RealFood',
source: ["Spinach", "Kale", "Coconut", "Avocado", "Banana", "Granola", "Beets"]
});
});
</script>
</head>
<body>
<div style="width: 1000px; height: 300px;">
<div style="float: left; width: 500px">
<h3>Hungry?</h3>
<input class="typeahead" type="text" placeholder="Food Item" autocomplete="off">
</div>
</div>
</body>
</html>发布于 2015-11-07 16:36:30
使用Bloodhound尝试包括到提前输入的完整路径。请参阅打字机-示例
<!doctype html>
<html lang="en">
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<div style="width: 1000px; height: 300px;">
<div style="float: left; width: 500px">
<h3>Hungry?</h3>
<input class="typeahead" type="text" placeholder="Food Item" autocomplete="off">
</div>
</div>
<script src="http://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var food = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: ["Spinach", "Kale", "Coconut", "Avocado", "Banana", "Granola", "Beets"]
});
$('.typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
}, {
name: 'RealFood',
source: food
});
});
</script>
</body>
</html>
发布于 2015-11-07 13:38:19
“打字机”对我也不起作用,但“威索普尔特”却是这样:
https://stackoverflow.com/questions/33583273
复制相似问题