Hi,

I wish to pass an extra parameter to the Autocomplete query URL that
will determine the name of the current input field. The URL will then
know what field is requesting the data and can return the relevant
data.
E.g. It could be list of countries or a group of surnames already in
the database.

I have read the documentation and thought the extraParams option would
do this but i'm struggling with the correct syntax.

The example below will pass an undefined value for 'fieldname' as $
(this) is out of scope within the extraParams function. Is there a way
I can access the inputs field name dynamically so i don't have to bind
the autocomplete function to each individual input?

$(".autocomlete").autocomplete(url, {
   extraParams: {
       fieldname: function() { return $(this).attr("name"); }
   }
});

http://docs.jquery.com/Plugins/Autocomplete

Thanks for your time.


Reply via email to