src/Eccube/Resource/template/admin/Product/_parts/js_product_spec.twig line 1

Open in your IDE?
  1. <script>
  2.     $(function() {
  3.         const itemClass = '.product_spec_row';
  4.         const $body = $('#product_spec_body');
  5.         let index = $body.find(itemClass).length;
  6.         function addForm() {
  7.             const prototype = $body.data('prototype');
  8.             const newForm = prototype.replace(/__name__/g, index);
  9.             $body.append(newForm);
  10.             index++;
  11.         }
  12.         $('#add_product_spec').on('click',addForm);
  13.         $(document).on('click','#remove_product_spec',function() {
  14.             if(!confirm('削除しますか?')) {
  15.                 return false;
  16.             }
  17.             const deleteIndex = $(this).data('index');
  18.             $(document).find('#product_spec_row'+deleteIndex).remove();
  19.         });
  20.     });
  21. </script>