Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda