1
我在Wordpress插件中使用jQuery自動完成。無法聚焦時,如何取消ajax/autocomplete? $first_id
由PHP傳遞並允許多個實例。jquery自動完成取消未聚焦
jQuery(document).ready(function ($){
$("#'.$first_id.'").autocomplete({
source: function(req, add){
$.getJSON("'.site_url().'/wp-admin/admin.php?page=church_admin/index.php&action=get_people&callback=?", req, function(data) {
//create array for response objects
var suggestions = [];
//process response
$.each(data, function(i, val){
suggestions.push(val.name);
});
//pass array to callback
add(suggestions);
});
},
select: function (event, ui) {
var terms = $("#'.$first_id.'").val().split(", ");
// remove the current input
terms.pop();
console.log(terms);
// add the selected item
terms.push(ui.item.value);
console.log(terms);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
$("#'.$first_id.'").val(this.value);
return false;
},
minLength: 3,
});
});
能否請你澄清你的問題:當自動完成是通過聽取
close
事件與任何關閉您可以刪除嗎? 「無焦點時取消ajax /自動完成」是什麼意思? – 2013-03-25 00:22:26當ajax腳本找不到任何東西,並且如果移動到下一個表單域時,輸入欄會保持灰色並顯示加載gif。我想要停止! – andymoyle 2013-03-25 07:27:35
「當ajax腳本找不到任何東西時,」輸入字段保持灰色並帶有加載gif「jQuery Autocomplete不會使字段變灰或顯示加載gif。那些必須在你自己的代碼中,這是沒有顯示。 – Danack 2013-03-25 08:42:21