SHARE
TWEET

Untitled

a guest Aug 21st, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('#deleteRow').closest('.form-group').hide();
  2.  
  3. $('#addRow').on('click', function (e) {
  4.     var len = $('.child-border').length + 1;
  5.     var head = len + 1;
  6.     $('#cabecera').text("Beneficiario Final N°" + head);
  7.     $('.parent-border').clone().find(':input').each(function (idx, ele) {
  8.         ele.name = ele.name + len;
  9.         ele.id = ele.id + len;
  10.         ele.value = '';
  11.     }).end().find('.form-group').toggle(true).end()
  12.             .toggleClass('parent-border child-border').hide()
  13.             .appendTo('#container').slideDown('slow');
  14. });
  15.  
  16. $('button.btn:contains("Save")').on('click', function (e) {
  17.     var jsonData = $('form.form-horizontal')
  18.             .find(':input:not(button)').get()
  19.             .reduce(function (acc, ele) {
  20.                 acc[ele.name || ele.id] = ele.value;
  21.                 return acc;
  22.             }, {});
  23. });
  24.  
  25. $('#container').on('click', '[id^=deleteRow]', function(e) {
  26.     var jsonData = $(this).closest('.child-border, .parent-border')
  27.             .find(':input:not(button)').get()
  28.             .reduce(function (acc, ele) {
  29.                 acc[ele.name || ele.id] = ele.value;
  30.                 return acc;
  31.             }, {});
  32.     $(this).closest('.child-border, .parent-border').remove();
  33. });
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