Good day!

I use autocomplete widget and connect to several input

Jquery:

  $("input[id^='reis_owner_id']").autocomplete({ source: "library/_ajax_profile.php?get_autocomplete_owner_for_contract", minLength: 3, select: function(event, ui) {}, search: function() { $(this).addClass('ui-autocomplete-loading'); }, open: function(event, ui) { $(this).removeClass('ui-autocomplete-loading'); $("#ui-id-1").css("left", parseInt($("#ui-id-1").css("left")) + "px"); } }) 

HTML:

 <input type="text" id="reis_owner_id123" class="input_guide ui-autocomplete-input" value="Вася" /> <input type="text" id="reis_owner_id01234" class="input_guide ui-autocomplete-input" value="Вася" /> 

Well, etc., that is, I connect the car reis_owner_id to the filter for all input whose id begins with reis_owner_id . How to find out in the select event, with which input is the widget working now?

    2 answers 2

    Use $(this)

    For example, you can find out the specific id - $(this).attr('id') . In your case, you can transfer this id to the server and process it there.

      source: "library/_ajax_profile.php?get_autocomplete_owner_for_contract&id=" + $(this).attr('id') 

      The problem was that $(this) did not return an element, but an object with which the plugin worked.

      • Write down your decision in more detail so that users can understand what the problem was - Yuri