Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _dynamicTable(){
- // clone the first table row after clicking on duplicate row
- $('.duplicate-row').click(function(){
- var tableId = $(this).attr('href');
- var initial = $(''+tableId+' tr').length;
- // Clone the first table row TR and duplicate
- var newLine = $(tableId).find('tr:eq(1)').clone();
- $(tableId).append(newLine);
- // Increment input fields when the user add a new quote line
- var itemPrice = $(tableId).find('tr:last .item-price').attr('id', 'item-price-'+initial);
- var itemQuantity = $(tableId).find('tr:last .item-quantity').attr('id', 'item-quantity-'+initial);
- var itemDiscount = $(tableId).find('tr:last .item-discount').attr('id', 'item-discount-'+initial);
- var itemName = $(tableId).find('tr:last .item-name').attr('id', 'item-name-'+initial);
- var itemReference = $(tableId).find('tr:last .item-reference').attr('id', 'item-reference-'+initial);
- var itemTotal = $(tableId).find('tr:last .item-total').attr('id', 'item-total-'+initial);
- //
- $(tableId).find('tr:last .item-line').val(initial);
- // Turn free the inputs fields since we clone the first line each time user click on add new line button
- $(tableId).find('tr:last input.form-control').val('');
- return false;
- });
- // remove table row on delete-row button click
- $('.table').on('click', '.delete-row', function(){
- var tableId = $(this).attr('href');
- if($(''+tableId+ ' > tbody > tr').length > 1){
- $(this).closest('tr').remove();
- window._ajaxForm("#setQuoteItems");
- }
- return false;
- });}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement