Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
Repeater issue/problm

We are trying to use this repeater: https://www.jqueryscript.net/form/Form-Fields-Repeater.html

It seems there is problem if you look at the demo. https://www.jqueryscript.net/demo/Form-Fields-Repeater/

Try on demo to add for example four groups.(press three times add button).

Then remove all four groups by pressing Delete button.

Then press add again to add a new group.

If you inspect the name element it is:

The problem is with test[4]name. Normally it should be test[0]name.

It seems that when you delete element does not delete the counting.

So if you play a little bit with delete/add buttons counting is wrong.

Javascript of this is :

    jQuery.fn.extend({
     createRepeater: function () {
         var addItem = function (items, key) {
        var itemContent = items;
        var group = itemContent.data("group");
        var item = itemContent;
        var input = item.find('input,select');
        input.each(function (index, el) {
            var attrName = $(el).data('name');
            var skipName = $(el).data('skip-name');
            if (skipName != true) {
                $(el).attr("name", group + "[" + key + "]" + attrName);
            } else {
                if (attrName != 'undefined') {
                    $(el).attr("name", attrName);
                }
            }
        })
        var itemClone = items;
        $("<div class='items'>" + itemClone.html() + "<div/>").appendTo(repeater);
    };
    /* find elements */
    var repeater = this;
    var items = repeater.find(".items");
    var key = 0;
    var addButton = repeater.find('.repeater-add-btn');
    var newItem = items;
    if (key == 0) {
        items.remove();
        addItem(newItem, key);
    }

    /* handle click and add items */
    addButton.on("click", function () {
        key++;
        addItem(newItem, key);
    });
}
 });

Have anyone ever used this repeater? or have a version of this that works correct?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda