ram*_*mya 13 jquery jquery-plugins jquery-autocomplete
我试图通过jquery auto complete plugin实现自动完成.一个简单的自动完成工作对我来说.我无法实现逗号分隔自动完成.
请帮我解决我的错误.
我的jquery代码:
$(document).ready(function() {
$.getJSON('/releases/new.json', function() {
alert("inside getJson");
alert(data1);
$('#release_tester_tokens').autocomplete({source:names,multiple: true});
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢,Ramya.
DOK*_*DOK 13
看看这个演练是否有帮助.它包含以下代码,允许用户输入以逗号分隔的多个搜索词:
$("#<%= txtMultipleName.ClientID %>").autocomplete({
source: function (request, response) {
$.getJSON("AutoComplete.ashx", {
term: extractLast(request.term)
}, response);
},
search: function () {
// custom minLength
var term = extractLast(this.value);
if (term.length < 1) {
return false;
}
},
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;
}
});
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
Run Code Online (Sandbox Code Playgroud)
jQuery UI自动完成页面上还有大量信息.
| 归档时间: |
|
| 查看次数: |
13883 次 |
| 最近记录: |