Autocomplete select event
Good afternoon!
I use the autocomplete widget and connect it 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 use the filter to connect the auto kit to all input
that id
starts with reis_owner_id
.
How do I find out in the select
event which input
the widget is currently working with?
0
2 answers
Use $(this)
For example, you can find out a specific id - $(this).attr('id')
. In your case, you can pass this id to the server and process it there
source: "library/_ajax_profile.php?get_autocomplete_owner_for_contract&id=" + $(this).attr('id')
1
Author: Vadim Prokopchuk, 2017-02-08 19:29:37
The problem was that $(this)
returned not an element, but an object that the plugin was working with.
-1
Author: Sergey P, 2017-02-08 20:34:03