Reputation: 28763
Iam using autocomplete for all my input fields like
$('input').autocomplete({
minLength: 1,
source: "{site_url}publish/my_autocomplete"
});
it is working fine,but when I want to send the selected input id like
$('input').autocomplete({
minLength: 1,
source: "{site_url}publish/my_autocomplete?key="+$(this).attr('id')
});
it is not working and key is undefined,can anyone suggest me for that
Upvotes: 0
Views: 85
Reputation: 68440
In your code this
doesn't represent the current input
as you're assuming.
Try with this
$('input').each(function(){
var $this = $(this);
$this.autocomplete({
minLength: 1,
source: "{site_url}publish/my_autocomplete?key=" + $this.attr('id')
});
})
Upvotes: 1