GautamD31
GautamD31

Reputation: 28763

Autocomplete not passing extra value

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

Answers (1)

Claudio Redi
Claudio Redi

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

Related Questions