change event
$('.amount').on('change','input', function(){
alert('hello!');
});
dynamicly created item:
<tr id="row{{$data['product_id']}}">
<td><input type="checkbox" name="product[]" value="{{$data['product_id']}}"></td>
<td>{{$data['product_id']}}</td>
<td class="amount">{!! Form::input('number','qty',$data['qty'],['id'=>$data['product_id'],'min'=>'1','max'=>\App\Product::find($data['product_id'])->quantity,'required'=>'required'])!!}
</td>
<td>{{$data['stock']}}</td>
<td id="rowprice{{$data['product_id']}}">{{$data['price']}} $</td>
<td id="rowsum{{$data['product_id']}}">{{$data['qty']*$data['price']}} $</td>
</tr>
adding this item:
$('#addProduct').click(function (e) {
$('#qty').attr('required', 'required');
$('#product_id').attr('required', 'required');
e.preventDefault();
var product_id = $('#product_id').val();
var data = $("#editOrderContent").serializeArray();
data.push(addProduct);
$.ajax({
type: 'POST',
dataType: 'JSON',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: $('#editOrderContent').attr('action'),
data: data,
success: function (html) {
if (html.success) {
$('#summary').before(html.tdProduct);
}
}
});
});
So when I try to change the value of qty input with freshly created item, event doesn't trigger, but when I reload page, it does.