我正在使用这个jquery 中继器。
我对表单的每次加法使用自定义计算,例如将一个输入与另一个输入相乘,然后得出乘法结果的总和。
问题是,当我们单击删除时,它只是隐藏该行,但不删除该项目的值,当我们删除另一个项目时,它将删除隐藏的第一个项目,并且我的计算得到更新。
我检查删除项目时的类数,第一次删除时它不会减少,第二次删除时它总是减少,
如何完全删除该行及其值?
var _CalTotal = function () {
console.log($(".billitem_quantity").length );
//Calculate total of quantity
var total_quantity = 0;
$(".billitem_quantity").each(function(){
total_quantity += parseFloat($(this).val());
});
$('#itemquantity_total').val(total_quantity.toFixed(2));
**//Calculate total of amount**
var total_amount = 0;
$(".billitem_total").each(function(){
total_amount += parseFloat($(this).val());
});
$('#bill_total').val(total_amount.toFixed(2));
console.log('test');
}
下面是隐藏的代码,
hide: function(deleteElement) {
Swal.fire({
title: "Are you sure to cancel this order?",
text: "You will not able to revert this",
icon: "question",
showCancelButton: true,
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, revert it!",
reverseButtons: true,
}).then(function(result) {
if (result.value) {
$(this).slideUp(deleteElement);
//I guess something is missing here to delete that item with first delete fire.
_CalTotal(); //Here i am calling calltotal function.
} else if (result.dismiss === "cancel") {
}
});
},
犯罪嫌疑人X
相关分类