I'm using the Clone function of jquery to be able to replicate a div . However, removing these elements, regardless of the quantity that has been replicated, always removes the div by complete. I need it removed line by line.
Form Code:
<div class="row">
<a class="btn btn-info btn- pull-right" id="add-more-btn" title="Adicionar mais arquivos">Adicionar</a>
<a class="btn btn-warning btn-circle pull-right" id="remove-inputFile-btn">-</a>
</div>
<div class="row arquivo_upload" id="uploadArquivoId">
<div class="col-md-6" >
<?= $form->field($model, '[0]descricao')->textInput(['maxlength' => true]) ?>
</div>
<div class="col-md-6 ">
<?= $form->field($model, '[0]arquivo_url')->fileInput()?>
</div>
$('#add-more-btn').on('click', function() {
var clone = $('#uploadArquivoId').clone();
var cloneInput = clone.find('input');
var index = $('.arquivo_upload').length;
$(cloneInput[0]).attr('name', 'ArquivoDocumental['+index+'][descricao]')
$(cloneInput[1]).attr('name', 'ArquivoDocumental['+index+'][arquivo_url]')
$(cloneInput[2]).attr('name', 'ArquivoDocumental['+index+'][arquivo_url]')
$('#row-clone').append(clone);
});
$('#remove-inputFile-btn').on('click', function() {
$('#row-clone').remove();
});