2017-02-20 3 views
0

Ich habe diese Tabelle:Zahleneingabe und jquery

<table id="product" class="table table-bordered table-striped"> 
    <thead> 
    <tr> 
     <th>Id</th> 
     <th>Cantidad</th> 
     <th>Producto</th> 
     <th>Marca</th> 
     <th>Precio</th> 
     <th>Importe</th> 
     <th>Serial</th> 
    </tr> 
    </thead> 
    <tbody> 
    </tbody> 
</table> 

I Zeilen die Tabelle mit diesem jquery Code hinzu:

$("#name").autocomplete({ 
    source: 'http://sosacelulares.com/index.php/product/search', 
    minLength: 1, 
    select: function (event, ui) { 
     var value = ui.item.value; 
     var data1 = value.split("-"); 
     var data = data1[0].split(" "); 
     $("#product").show(); 

     var v = data[1]; 

     $.ajax({ 
      async:true, 
      type: "POST", 
      dataType: "html", 
      contentType: "application/x-www-form-urlencoded", 
      url:"http://sosacelulares.com/index.php/product/get", 
      data:"id="+v, 
      success: function(response) { 
      var returnedData = JSON.parse(response); 

      $("#product > tbody").append('<tr><td>' + returnedData[0].id_product + '</td><td><input min="1" type="number" style="width: 100px;" value="" class="form-control quantity" id="quantity" placeholder="Cantidad" required></td><td>' + returnedData[0].name + '</td><td>' + returnedData[0].brand + '</td><td><input type="text" style="width: 100px;" value="' + returnedData[0].buy_price + '" class="form-control" placeholder="Precio" required></td><td></td><td><a href=""><button type="submit" class="btn btn-success">Agregar Serial</button></a></td></tr>'); 
      } 
     }); 
    }, 

}); 

ich für einen Namen in einer Texteingabe anschauen und dann, wenn Ich finde es ich füge es einfach in den Tisch. Das Problem ist, dass die Zeilen, die ich addieren sie ein Zahleneingabefeld haben, dass sie die Menge hinzuzufügen ist ich es wie folgt testen:

$(".quantity").change(function() { 
    alert(1); 
}); 

Ich weiß nicht, warum, wenn ich die Menge Eingangs ändern, es ist ubicated innerhalb der neuen Zeile, die ich mit jquery hinzugefügt habe funktioniert es nicht, wenn ich eine Änderung mache, erscheint die Warnung nicht, was mache ich schlecht? Vielen Dank!

+0

die '.on'-Funktion verwenden. '$ (". quantity "). on ('change', function() {});' –

Antwort

0

Try this:

$(document).on("change", ".quantity", function() { 
    alert(1); 
});