jquery.calculate を使用して請求システムを作成しています。
var newIDSuffix = 2;
$(".invoice_items").delegate('#add-row', 'click', function () {
var lastRow = $("tr.lastrow");
var cloned = $("tr.default").clone().removeAttr('class');
cloned.find('td#total_item_1').each(function() {
$(this).attr('id', 'total_item_'+2);
});
cloned.find('input, select').each(function() {
var id = $(this).attr('id'),
name = $(this).attr('name');
id = id.substring(0, id.length-1) + newIDSuffix;
$(this).attr('id', id);
});
cloned.insertBefore(lastRow).find('input:text').val('');
newIDSuffix++;
});
// update the plug-in version
$("#idPluginVersion").text($.Calculation.version);
// bind the recalc function to the quantity fields
$("input").bind("keyup", recalc);
// run the calculation function now
recalc();
$("input").bind("keyup", recalc);
// run the calculation function now
recalc();
これが私がこれまでに行ったことです。http://jsfiddle.net/aliharis/VXZe8/
問題は、行を動的に追加すると、値を入力すると、金額列と合計が更新されないことです。しかし、動的に追加された行に値を入力し、最初の行に戻って値を入力すると、動的に追加されたフィールドを含めて計算されます。
何が問題なのかわかりませんでした。