Odevzdávátko: fix JS formsetu

This commit is contained in:
Pavel "LEdoian" Turinsky 2021-03-30 19:41:08 +02:00
parent dac2cc8b51
commit d61f723636

View file

@ -26,8 +26,9 @@ function deleteForm(prefix, btn) {
if (total >= 1){
btn.closest('tr').remove();
var forms = $('.hodnoceni');
$('#id_' + prefix + '-TOTAL_FORMS').val(forms.length);
for (var i=0, formCount=forms.length; i<formCount; i++) {
var formCount = forms.length - 1; // There is one extra such form hidden as template!
$('#id_' + prefix + '-TOTAL_FORMS').val(formCount);
for (var i=0; i<formCount; i++) {
$(forms.get(i)).find(':input').each(function() {
updateElementIndex(this, prefix, i);
});