Reputation: 47290
$("input[type=text]").autocomplete({
minLength: 3,
source: function (request, response) {
alert( $(this).val() );
I have 3 different input text box's, but $(this).attr("id")
or this.id
both returned undefined
Upvotes: 0
Views: 50
Reputation: 171669
Not sure what is available inside source
regarding this
. You can always log it to console to see what is returned. The following pattern is helpful for implementing plugins on many elements
$("input[type=text]").each(function() {
var id = this.id;
$(this).autocomplete({
minLength: 3,
source: function(request, response) {
alert(id);
}
});
});
Upvotes: 1