jQueryUIのオートコンプリート機能を使用しています。それは正しくリストにアイテムを与え、私はリストから選択をすることができます。私が抱えている問題は、ソースイベントで使用されている配列から選択されたアイテムのインデックスを取得する方法です。
var options = {
select: function() {
// problem is here, I'm not able to see the correct index number of the selected item and always say -1
alert($.inArray($("#searchAText").val()), arrayA);
},
source: function(req, response) {
var re = $.ui.autocomplete.escapeRegex(reg, term);
var matcher = new RegExp("^" + re + "i");
response($.grep(arrayA, function(item, index) {
return matcher.test(item);
}));
}
};
}