ajax - cannot bind values to dynamically created textbox jquery -


i'm trying bind jquery autocomplete result dynamically created textboxes, have searched internet , forums couldn't found appropriate solution, i'm sharing code

jquery:

function bindautocomplete(classname) {     $("." + classname).autocomplete({         source: function (request, response) {             $.ajax({                 url: '/admin/ticket/getpart',                 type: "get",                 datatype: "json",                 data: { term: request.term },                 success: function (data) {                     if (data != null) {                         if (data.length > 0) {                             response($.map(data, function (item) {                                 return { label: item.partnumber, value: item.partnumber };                             }))                         }                         else {                             response([{ label: 'no results found.' }]);                         }                     }                 }             })         },     });  }  function binddata() {     var errormsg = "";     var amount = $('.inputs').val();      $.ajax({         type: "get",         url: '/admin/ticket/getpart',         data: { 'term': amount },         datatype: "json",         success: function (data) {             if (data != null) {                 if (data.length > 0) {                     $('#manufacturer').val(data[1].manufacturer);                     $('#datecode').val(data[0].datecode);                     $('#package').val(data[0].packagecase);                     $('.buyingprice').val(data[0].price);                 }                 else {                     $('#manufacturer').val('');                     $('#datecode').val('');                     $('#package').val('');                     $('.buyingprice').val('');                 }             }          },         error: function (jqxhr, exception) {             $('#error').html(jqxhr)         }     }); };  // fetch part number $(document).ready(function () {     bindautocomplete('inputs');     $('.inputs').keyup(binddata) });  $("#addmore").click(function () {      $("#maintable").each(function () {          var tds = '<tr>';          jquery.each($('tr:last td', this), function () {             tds += '<td>' + $(this).html() + '</td>';         });         tds += '</tr>';          if ($('tbody', this).length > 0) {              $('tbody', this).append(tds);          //   binddata();             bindautocomplete('inputs');             $("#delete").fadein('200');         }         else {             $(this).append(tds);             bindautocomplete('inputs');         //    binddata();          }     });  }); 

html:

<table id="maintable">         <thead>             <tr>                 <th>                     part no                 </th>                 <th>                     mfg                 </th>                 <th>                     dc                 </th>                 <th>                     pkg                 </th>                 <th>                     qty. need                 </th>                 <th>                     qty. offer                 </th>                 <th>                     bp                 </th>                 <th>                     bp(usd)                 </th>                 <th>                     amt (usd)                 </th>                 <th>                     lt days                 </th>                 <th>                     desc                 </th>                 <th>                     note                 </th>             </tr>         </thead>         <tbody>             <tr>                 <td>                     <input class="inputs" type="text" name="abcd" id="partnumber23" style="width:130px;" />                 </td>                 <td>                     <input class="text-box single-line" id="manufacturer" name="manufacturer" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="manufacturer" data-valmsg-replace="true"></span>                 </td>                 <td>                     <input class="text-box single-line" id="datecode" name="datecode" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="datecode" data-valmsg-replace="true"></span>                 </td>                 <td>                     <input class="text-box single-line" id="package" name="package" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="package" data-valmsg-replace="true"></span>                 </td>                 <td>                     <input class="text-box single-line" data-val="true" data-val-number="the field quantity must number." data-val-required="the quantity field required." id="quantity" name="quantity" style="width:35px;" type="number" value="" />                     <span class="field-validation-valid" data-valmsg-for="quantity" data-valmsg-replace="true"></span>                 </td>                 <td>                     <input class="text-box single-line" id="customquantity" name="customquantity" style="width:35px;" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="customquantity" data-valmsg-replace="true"></span>                 </td>                 <td>                     <input class="buyingprice text-box single-line" id="buyingprice" name="buyingprice" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="buyingprice" data-valmsg-replace="true"></span>                 </td>                 <td>                     <input id="bpusd" name="convertedbp" readonly="readonly" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="convertedbp" data-valmsg-replace="true"></span>                 </td>                 <td>                     <input id="amtusd" name="convertedamount" readonly="readonly" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="convertedamount" data-valmsg-replace="true"></span>                     <span id="error" class="error"></span>                 </td>                 <td>                     <input id="ltdays" name="ltdays" type="text" value="" />                     <span class="field-validation-valid" data-valmsg-for="ltdays" data-valmsg-replace="true"></span>                 </td>                 <td>                     <select class="drop" id="description" name="description">                         <option>original rohs</option>                         <option>rohs compliance</option>                     </select>                     <span class="field-validation-valid" data-valmsg-for="description" data-valmsg-replace="true"></span>                 </td>                 <td>                     <textarea class="txtarea text-box multi-line" id="note" name="note" placeholder="any note ticket"></textarea>                     <span class="field-validation-valid" data-valmsg-for="note" data-valmsg-replace="true"></span>                 </td>             </tr>         </tbody>     </table> 

it working on single row of textbox not working on dynamic text boxes, please guide me i'm stuck on hours


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -