[英](jqueryUI) How can I turn autocomplete off?
So I'm trying to recreate Facebooks tagging system in jquery. 因此,我试图在jquery中重新创建Facebooks标记系统。 I can not use any plugins.
我不能使用任何插件。 I have some of it already:
我已经有一些了:
<html lang="de">
<head>
<title>Autocomplete</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var triggered = false;
var trigger = "@";
var index = -1;
$("input").autocomplete({
source: [
"AAB",
"AAC",
"CCE",
"CCG",
"IIU",
"IIO"],
search: function () {
if (!triggered) {
return false;
}
},
select: function (event, ui) {
var text = this.value;
var pos = text.lastIndexOf(trigger);
this.value = text.substring(0, pos + trigger.length) + ui.item.value;
triggered = false;
return false;
},
focus: function () {
return false;
},
minLength: 0
}).on("keyup", function () {
var text = this.value;
var len = text.length;
var last;
var query;
if (triggered) {
index = text.lastIndexOf(trigger);
query = text.substring(index + trigger.length);
$(this).autocomplete("search", query);
if (index === -1) {
triggered = false;
}
} else if (len >= trigger.length) {
console.log("ELSE IF")
last = text.substring(len - trigger.length);
triggered = (last === trigger);
}
});
});
</script>
</head>
<body>
<label>Input something here:</label>
<br>
<input type="text" value="" autofocus="true" />
</body>
</html>
So i got the following problem with it: Tagging works just fine, but after I hit the @ once the Autocomplete doesn't go away. 所以我遇到了以下问题:标记工作得很好,但是一旦我点击@之后,自动完成功能就不会消失。 It stops searching but it still displays that there were no results found.
它停止搜索,但仍显示未找到结果。 I tried to solve it as follows:
我试图解决如下:
So my Question: Does anybody know a trick to how this could work? 所以我的问题是:有人知道如何发挥作用的窍门吗? do I have to rewrite my code somehow?
我是否必须以某种方式重写我的代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.