I think it's just not in the scope. I haven't looked into it. How about looping through each result set and assigning the option individually. In addition to your autocomplete initialization code, add this (not tested):
$("input.vAutocompleteField").each(function() { var field = this; $(field).setOptions({ extraParams: { extra_var: function() { return field.id; } } }); }); On Sep 28, 10:00 pm, patrickk <patr...@vonautomatisch.at> wrote: > I would like to send the ID of the autocomplete-field to the ajax- > script. > I thought that $(this) refers to the input-field (having my initial > example in mind). > > isn´t it possible to use $(this) within the autocompleter? how would > you pass the ID of the current autocomplete-field to the ajax-script > (assuming that you have several autocomplete-fields on one page)? > > thanks, > patrick > > On 29 Sep., 02:35, James <james.gp....@gmail.com> wrote: > > > By the way, > > 'extra_var': function() { > > return $("#extra_var").attr('id'); > > > } > > > Would return "extra_var" since $("#extra_var").attr('id'); is > > "extra_var". > > I'm not sure what you're trying to achieve if that's not what you > > want. > > > On Sep 28, 2:34 pm, James <james.gp....@gmail.com> wrote: > > > > "extra_var" does not map to the ID of the input field. It is the name > > > that is going to be sent along with the AJAX request to your script. > > > (e.g. /autocomplete_lookup/? > > > q=my_search_text_blahablhablah&extra_var=12345) > > > > You have to change it so it's: > > > 'extra_var': function() { > > > return $("#extra_var").attr('id'); > > > > } > > > > On Sep 26, 8:39 am, patrickk <patr...@vonautomatisch.at> wrote: > > > > > I´m a bit confused, because the following doesn´t seem to work and I > > > > have no idea why ... after searching google for a couple of hours and > > > > trying different solutions, I´m posting this here and hope that > > > > someone can help. > > > > > $("input.vAutocompleteField").autocomplete('/ > > > > autocomplete_lookup/', { > > > > highlight: false, > > > > mustMatch: false, > > > > matchContains: true, > > > > cacheLength: 20, > > > > minChars: 2, > > > > extraParams: { > > > > 'extra_var': function() { > > > > return $(this).attr('id'); > > > > } > > > > } > > > > }); > > > > > "extra_var" should be the ID of the current input-field. > > > > > this is probably just me don´t seeing what´s wrong ... so any help is > > > > appreciated. > > > > > thanks, > > > > patrick > >