Skip to content

Commit cd61b1f

Browse files
author
Alexander Nesterov
committed
refactoring
1 parent 576e43e commit cd61b1f

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/assets/src/js/jquery.multipleInput.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131

132132
$wrapper.on('click.multipleInput', '.js-input-clone', function (e) {
133133
e.stopPropagation();
134-
addInput($(this), getRowValues(e));
134+
addInput($(this), getRowValues($(this)));
135135
});
136136

137137
var i = 0,
@@ -435,10 +435,9 @@
435435
}).length;
436436
};
437437

438-
var getRowValues = function (event) {
439-
var tr = $(event.currentTarget).closest('tr');
438+
var getRowValues = function (element) {
440439
var values = {};
441-
tr.find('td').each(function (index, value) {
440+
element.closest('tr').find('td').each(function (index, value) {
442441
$(value).find('input, select, textarea').each(function (k, v) {
443442
var ele = $(v),
444443
id = getInputId(ele),

src/renderers/ListRenderer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ private function renderRowContent($index = null, $item = null)
140140
$content[] = $this->renderActionColumn($index);
141141
}
142142

143-
$this->cloneButton && $content[] = $this->renderCloneColumn();
143+
if ($this->cloneButton) {
144+
$content[] = $this->renderCloneColumn();
145+
}
146+
144147
$content = Html::tag('tr', implode("\n", $content), $this->prepareRowOptions($index, $item));
145148

146149
if ($index !== null) {

src/renderers/TableRenderer.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public function renderHeader()
6363

6464
$cells[] = $this->renderButtonHeaderCell($button);
6565

66-
$this->cloneButton && $cells[] = $this->renderButtonHeaderCell();
66+
if ($this->cloneButton) {
67+
$cells[] = $this->renderButtonHeaderCell();
68+
}
6769
}
6870

6971
return Html::tag('thead', Html::tag('tr', implode("\n", $cells)));
@@ -198,7 +200,10 @@ private function renderRowContent($index = null, $item = null)
198200
$cells[] = $this->renderCellContent($column, $index);
199201
}
200202
}
201-
$this->cloneButton && $cells[] = $this->renderCloneColumn();
203+
if ($this->cloneButton) {
204+
$cells[] = $this->renderCloneColumn();
205+
}
206+
202207
if (!$isLastRow) {
203208
$cells[] = $this->renderActionColumn($index);
204209
}

0 commit comments

Comments
 (0)