Aşağıdaki kod verildiğinde, işlevine, $.ajax
çağrısında bulunan otomatik tamamlama olan girişe nasıl başvurabilirim? Ne $(this)
veya $e
çalışır.JQuery otomatik tamamlamasındaki metin girişine başvurma
$('.parent-input').autocomplete({
source: function(request, response) {
var element = this.element; // <-- this.element is the input the widget is bound to.
$.ajax({
url: "/chunky/bacon",
dataType: 'json',
data: {
product_id: $('#product-id').val(),
term: request.term
},
success: function(data){
var resultCount = data.length;
// element still refers to the input the widget is bound on.
// for example:
element.addClass("blue");
response(data);
}
});
},
minLength: 2,
select: function(event, ui){
addAssociatedProduct(ui.item.id, ui.item.value);
$(this).val('');
return false;
}
});
orada sınıfın birden elemanları 'ebeveyn-input' Are:
– hughesBirden çok örnek var – bjork24