From 5ec6787e3cb731dc148dc9468c6d4d747834ba72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=A4=A7=E5=89=A9?= Date: Sun, 27 Nov 2022 17:23:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86index=E5=94=AF=E4=B8=80=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=87=BA=E7=8E=B0=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E6=88=96=E5=A4=9A=E4=B8=AA=E7=9B=B8=E5=90=8C=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=97=B6=E5=85=A8=E5=B1=80index=E5=8F=98=E9=87=8F=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Form/Field/HasMany.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Form/Field/HasMany.php b/src/Form/Field/HasMany.php index e8f4b09ed8..92acb3dbae 100644 --- a/src/Form/Field/HasMany.php +++ b/src/Form/Field/HasMany.php @@ -488,14 +488,14 @@ protected function setupScriptForDefaultView($templateScript) * {count} is increment number of current sub form count. */ $script = <<column = 0; $('#has-many-{$this->column}').off('click', '.add').on('click', '.add', function () { var tpl = $('template.{$this->column}-tpl'); - index++; + index_$this->column++; - var template = tpl.html().replace(/{$defaultKey}/g, index); + var template = tpl.html().replace(/{$defaultKey}/g, index_$this->column); $('.has-many-{$this->column}-forms').append(template); {$templateScript} return false; @@ -543,11 +543,11 @@ protected function setupScriptForTabView($templateScript) } }); -var index = 0; +var index_$this->column = 0; $('#has-many-{$this->column} > .header').off('click', '.add').on('click', '.add', function(){ - index++; - var navTabHtml = $('#has-many-{$this->column} > template.nav-tab-tpl').html().replace(/{$defaultKey}/g, index); - var paneHtml = $('#has-many-{$this->column} > template.pane-tpl').html().replace(/{$defaultKey}/g, index); + index_$this->column++; + var navTabHtml = $('#has-many-{$this->column} > template.nav-tab-tpl').html().replace(/{$defaultKey}/g, index_$this->column); + var paneHtml = $('#has-many-{$this->column} > template.pane-tpl').html().replace(/{$defaultKey}/g, index_$this->column); $('#has-many-{$this->column} > .nav').append(navTabHtml); $('#has-many-{$this->column} > .tab-content').append(paneHtml); $('#has-many-{$this->column} > .nav > li:last-child a').tab('show'); @@ -588,14 +588,14 @@ protected function setupScriptForTableView($templateScript) * {count} is increment number of current sub form count. */ $script = <<column = $('#has-many-{$this->column} table tbody').children().length; $('#has-many-{$this->column}').on('click', '.add', function () { var tpl = $('template.{$this->column}-tpl'); - index++; + index_$this->column=($('#has-many-{$this->column} table tbody').children().length)+1; - var template = tpl.html().replace(/{$defaultKey}/g, index); + var template = tpl.html().replace(/{$defaultKey}/g, index_$this->column); $('.has-many-{$this->column}-forms').append(template); {$templateScript} return false;