SHARE
TWEET

Untitled

a guest Jun 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function _dynamicTable(){
  2. // clone the first table row after clicking on duplicate row
  3. $('.duplicate-row').click(function(){
  4.     var tableId = $(this).attr('href');
  5.     var initial = $(''+tableId+' tr').length;
  6.     // Clone the first table row TR and duplicate
  7.     var newLine = $(tableId).find('tr:eq(1)').clone();
  8.     $(tableId).append(newLine);
  9.     // Increment input fields when the user add a new quote line
  10.     var itemPrice = $(tableId).find('tr:last .item-price').attr('id', 'item-price-'+initial);
  11.     var itemQuantity = $(tableId).find('tr:last .item-quantity').attr('id', 'item-quantity-'+initial);
  12.     var itemDiscount = $(tableId).find('tr:last .item-discount').attr('id', 'item-discount-'+initial);
  13.     var itemName = $(tableId).find('tr:last .item-name').attr('id', 'item-name-'+initial);
  14.     var itemReference = $(tableId).find('tr:last .item-reference').attr('id', 'item-reference-'+initial);
  15.     var itemTotal = $(tableId).find('tr:last .item-total').attr('id', 'item-total-'+initial);
  16.     //
  17.     $(tableId).find('tr:last .item-line').val(initial);
  18.     // Turn free the inputs fields since we clone the first line each time user click on add new line button
  19.     $(tableId).find('tr:last input.form-control').val('');
  20.     return false;
  21. });
  22.  
  23. // remove table row on delete-row button click
  24. $('.table').on('click', '.delete-row', function(){
  25.     var tableId = $(this).attr('href');
  26.     if($(''+tableId+ ' > tbody > tr').length > 1){
  27.         $(this).closest('tr').remove();
  28.         window._ajaxForm("#setQuoteItems");
  29.     }
  30.     return false;
  31. });}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top