jqh 4 سال پیش
والد
کامیت
da020a9312
3فایلهای تغییر یافته به همراه5 افزوده شده و 13 حذف شده
  1. 0 0
      resources/dist/dcat/js/dcat-app.js
  2. 0 0
      resources/dist/dcat/js/dcat-app.js.map
  3. 5 13
      src/Form/Field/ListField.php

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
resources/dist/dcat/js/dcat-app.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
resources/dist/dcat/js/dcat-app.js.map


+ 5 - 13
src/Form/Field/ListField.php

@@ -144,21 +144,13 @@ class ListField extends Field
 
         $this->script = <<<JS
 (function () {
-    $('.{$this->formatColumn()}-add').off()
+    var index = {$number};
     $('.{$this->formatColumn()}-add').on('click', function () {
-        var index = 0;
-         $(this).closest('table').children('tbody.list-value-table').children().each((i,child)=>{
-             let name = $(child).find('input').attr('name')
-             rep = /\[values\]\[\d+\]/;
-             name = rep.exec(name).pop();
-             index = Math.max(index,Number(name.slice(9,-1)));
-             console.log(index);
-         })
-         console.log(index);
-        var tpl = $(this).closest('div.form-group').next('template').html().replace('{key}', index+1);
-        $(this).closest('table').children('tbody.list-{$this->formatColumn()}-table').append(tpl);
+        var tpl = $('template.{$this->formatColumn()}-tpl').html().replace('{key}', index);
+        $('tbody.list-{$this->formatColumn()}-table').append(tpl);
+        
+        index++;
     });
-    $('tbody').off('click', '.{$this->formatColumn()}-remove');
     $('tbody').on('click', '.{$this->formatColumn()}-remove', function () {
         $(this).closest('tr').remove();
     });

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است