0
이 jquery 자동 완성을 클릭하면 팝업 효과를 추가 할 수 있습니까? 추가 할 수있었습니다.여러 단어를 클릭하면 jquery 자동 완성 팝업
.bind('focus', function() {
$(this).autocomplete("search");
그러나이 단어는 여러 단어로 작동하지 않습니다. 그래서 아래의 코드에 팝업 효과를 어떻게 추가합니까? 어떤 도움을 주시면 감사하겠습니다.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Multiple values</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$("#tags")
// don't navigate away from the field on tab when selecting an item
.bind("foucus", function(event) {
if (event.keyCode === $.ui.keyCode.TAB &&
$(this).data("ui-autocomplete").menu.active) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function(request, response) {
// delegate back to autocomplete, but extract the last term
response($.ui.autocomplete.filter(
availableTags, extractLast(request.term)));
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function(event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
return false;
}
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tag programming languages: </label>
<input id="tags" size="50" />
</div>
</body>
</html>
나는 당신을 시도했지만 작동하지 않습니다. – user2584325
"복수 단어"는 무엇을 의미합니까? – schmidtphil
위의 코드를 보면 예전 PHP를 입력 할 때 autocomplete가 일치를 표시하고 자바를 다시 선택하려고 할 때와 같은 것을 의미합니다. 곧 쉼표로 구분 된 하나의 입력 필드에서 여러 값 (단어)을 선택할 수 있습니다. – user2584325