标签:
关于jquery.ui.js中autocomplete动态获取远程数据后,值的返回。可通过select事件指定。
function log( message ) {
$("#docNames").text(message);
$( "#docNames" ).scrollTop(0);
}
$("#docNames").autocomplete({
source: function (req, res) {
$.ajax({
url: "http://gd.geobytes.com/AutoCompleteCity",
dataType: "jsonp",
data: {
q: req.term
},
success: function (data) {
res(data);
}
});
},
minLength: 3,
select: function( even, ui ) {
console.log(ui); //获取的值
log( ui.item ? ui.item.label : this.value); //item数组里面label所对应的值
console.log("Selected: " + ui.item.label);
console.log("Nothing selected, input was " + this.value)
}
});
标签:
原文地址:http://www.cnblogs.com/hzzt/p/5596517.html