在视图中有一个名为'添加/编辑产品'的按钮,当我点击它并在数量字段中输入一些值时,在“添加/编辑产品”按钮下面将创建一个表。
我的观点:
当我在另一个表中更改数据时,我想更改/更新模态数值中的数据。
我做了一点但它只改变了一个模态页面:
我在模态中使用了yajra数据表。 我的模态观点:
<!-- Modal -->
<div class="modal fade" id="productmodal" role="dialog">
<div class="modal-dialog prod_dia">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add /Edit Product</h4>
</div>
<div class="modal-body">
<section class="panel panel-primary">
<div class="panel-heading">
<b>Add /Edit Product</b>
</div>
<div class="panel-body product_body">
<div class="table-responsive maindiv">
<table class="table table-hover table-bordered prdb" id="productid">
<form name="proform">
<thead>
<th>Product</th>
<th>Price</th>
<th>Qty</th>
</thead>
<tbody>
@foreach($datapr as $k)
<tr>
<td>{{$k->brand}}-{{$k->pcode}}-{{$k->pgroup}}<input type="hidden" data-pcode='{{$k->pcode}}' class="qtyforpcode"></td>
<td>{{$k->price}}</td>
<td>
<input type="text" data-prid='{{$k->prid}}' data-brand='{{$k->brand}}' data-price='{{$k->price}}' data-pgroup='{{$k->pgroup}}' data-sprice='{{$k->sprice}}' data-pcode='{{$k->pcode}}' name="pr_qty" id="qty" class="form-control qty">
</td>
</tr>
@endforeach
</tbody>
</table>
</form>
</div>
</div>
</section>
</div>
<div class="modal-footer">
<input type="submit" value="Done" id="doneproduct" class="btn btn-primary customclose">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
在我的jQuery中,我尝试更新模态(但它只更改了模态中的一个页面)
$('.qtypr').on('change',function(){
var ttr=$(this).parent().parent();
var qty=ttr.find('.qtypr').val();//new value
var pcode=ttr.find('.qtypr').data('pcode');
console.log(qty);
console.log(pcode);
$('#productmodal .prod_dia .product_body .maindiv .prdb tr').each(function(){
var pcodetable=$(this).find('.qtyforpcode').data('pcode');
$(this).css("background-color", "yellow");
console.log("--pcodetable -----");
console.log(pcodetable);
if(pcodetable==pcode){
console.log("match one vale");
$(this).find('td .qty').val(qty);
}
});
});
有什么问题是因为模态或数据表分页?请帮帮我,我该如何更新