Der erste Teil des Codes wird zum Erstellen mehrerer Texboxen in gridview
verwendet.Autocomplete-Funktion bei Textbox keyup-Ereignis
Im zweiten Teil möchte ich Autocomplete-Funktionalität auf Textfelder keyup
Ereignis verwenden.
Der zweite Teil funktioniert nicht.
$(function() {
$('#cpContent_grdOrderDetail tr').attr('data-count', '0');
$('.bull').click(function() {
var NewRow = $(this).closest('tr');
var SrNo = $(this).closest('tr').find('.GridTextBox').val();
var no = parseInt(NewRow.attr('data-count'));
var newx = no + 1;
NewRow.attr('data-count', newx);
var ProductId = $(this).closest('tr').find('#hfProductId').val();
$(this).closest('tr').find('#hfAttachmentCount').val(no);
alert(ProductId);
var content = '<tr><td></td>';
content = content + '<td><input type="text" ID="txtAttachmentCode' + SrNo + '_' + no + '" class="AttachmentAutoFill" /><input type="hidden" class="AttachPId" ID="hfProductId' + SrNo + '_' + no + '" Value=' + ProductId + ' /></td>';
content = content + '<td><input type="text" ID="txtAttachName' + SrNo + '_' + no + '" /></td>';
content = content + '<td colspan=2></td>';
content = content + '<td><input type="text" ID="txtAttachmentQty' + SrNo + '_' + no + '"/></td>';
content = content + '<td><input type="text" ID="txtAttachCost' + SrNo + '_' + no + '"/></td>';
content = content + '<td colspan=3></td>';
content = content + '<td><input type="text" ID="txtAttachmentTotalCost' + SrNo + '_' + no + '"/></td>';
content = content + '</tr>';
$(content).insertAfter(NewRow);
return false;
});
$(document).on('keyup', '.AttachmentAutoFill', function() {
var ProductId = $(this).next('.AttachPId').val();
var FilterText = $(this).val();
$(this).autocomplete({
source: function (request, response) {
$.ajax({
url: '<%=ResolveUrl("~/WebService/GetItemsForAutoCompleteBox.asmx/GetAttachmentInfo") %>',
data: "{ 'ProductId': '" + $(this).next('.AttachPId').val() + "',FilterText'" + $(this).val() + "'}",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split('-')[0],
val: item.split('-')[1]
}
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
},
minLength: 1
});
});
});
Gibt es einen Fehler ?? –
es ist kein Fehler Problem ist es geht nicht in Autocomplete-Funktion dh $ (this) .autocomplete ({ – grnake
Fügen Sie Ihre HTML-Markup zu Ihrer Frage oder machen eine Geige –