Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/jquery.formset.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@
// Rather than remove this form from the DOM, we'll mark it as deleted
// and hide it, then let Django handle the deleting:
del.val('on');
row.hide();
row.slideUp();
forms = $('.' + options.formCssClass).not(':hidden');
} else {
row.remove();
row.slideUp(400, function(){row.remove();});
// Update the TOTAL_FORMS count:
forms = $('.' + options.formCssClass).not('.formset-custom-template');
forms = $('.' + options.formCssClass).not('.formset-custom-template').not(row);
totalForms.val(forms.length);
}
for (var i=0, formCount=forms.length; i<formCount; i++) {
Expand Down Expand Up @@ -194,7 +194,8 @@
buttonRow = $($(this).parents('tr.' + options.formCssClass + '-add').get(0) || this)
delCssSelector = $.trim(options.deleteCssClass).replace(/\s+/g, '.');
applyExtraClasses(row, formCount);
row.insertBefore(buttonRow).show();
row.hide();
row.insertBefore(buttonRow).slideDown();
row.find(childElementSelector).each(function() {
updateElementIndex($(this), options.prefix, formCount);
});
Expand Down
14 changes: 12 additions & 2 deletions tests/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
assert.equal($('#id_form-TOTAL_FORMS').val(), '1', 'Default form is present.');
$('#stacked-form .delete-row').trigger('click');
assert.equal($('#id_form-TOTAL_FORMS').val(), '0', 'Updated "Total Forms" count.');
assert.equal($('#stacked-form div').size(), 0, 'Removed form.');
stop();
setTimeout(function(){
assert.equal($('#stacked-form div').size(), 0, 'Removed form.');
start()
}, 600);
});

test('Test Max Forms', function (assert) {
Expand Down Expand Up @@ -176,7 +180,13 @@
assert.ok($btn.hasClass('btn-danger'), 'Remove button has class "btn-danger" applied to it.');
$btn.trigger('click');
assert.equal($('#id_form-TOTAL_FORMS').val(), '0', 'Updated "Total Forms" count.');
assert.equal($('#stacked-form div').size(), 0, 'Removed form.');

stop();
setTimeout(function(){
assert.equal($('#stacked-form div').size(), 0, 'Removed form.');
start()
}, 600);

});


Expand Down