Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Problema/problema del repetidor

Estamos tratando de usar este repetidor: https://www.jqueryscript.net/form/Form-Fields-Repeater.html

Parece que hay un problema si miras la demostración. https://www.jqueryscript.net/demo/Form-Fields-Repeater/

Pruebe la demostración para agregar, por ejemplo, cuatro grupos (presione tres veces el botón Agregar).

Luego elimine los cuatro grupos presionando el botón Eliminar.

Luego presione agregar nuevamente para agregar un nuevo grupo.

Si inspecciona el elemento de nombre es:

El problema es con test[4]name. Normalmente debería ser test[0]name.

Parece que cuando eliminas un elemento no elimina el conteo.

Entonces, si juegas un poco con los botones de eliminar/agregar, el conteo es incorrecto.

Javascript de esto es:

 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); }); } });

¿Alguien ha usado este repetidor? o tiene una versión de este que funciona correctamente?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!