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