Auto complete doesn't work on dynamically add textboxes
- $("#table tr td:last").live("keydown", function (e) {
- var keyCode = e.keyCode || e.which;
- if (keyCode == 9) {
- $("#table tr:last").after("<tr><td><input type='text' style='width: 140px'/></td><td><input type='text' style='width: 140px'/></td><td><input type='text' id='legid' class='acomp' style='width: 140px'/></td><td><input type='text' style='width: 140px'/></td><td><input type='text' style='width: 140px'/></td><td><input type='text' style='width: 140px'/></td></tr>");
- }
- });
- });
- function SearchText() {
- $("#table .acomp").autocomplete({
- source: function (request, response) {
- $.ajax({
- type: "POST",
- contentType: "application/json; charset=utf-8",
- url: "WebService.asmx/GetAutoCompleteData",
- data: "{'kwrds':'" + $('.acomp').val() + "'}",
- dataType: "json",
- success: function (data) {
- response(data.d);
- // $('#<%= legid.ClientID %>').find("tr").find("td").val;
-
- },
- error: function (result) {
- alert(result);
- }
- });
- }
- });
- }
I tried with ID and using a class but I still cannot retrieve the value out of the dynamically created textboxes.