Permalink
Browse files

Fixed #14303 -- Ensure that the ids created for new inlines are uniqu…

…e after interstitial deletions have occurred. Thanks to m0nonoke for the report, and Julien Phalip for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15422 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent baef1cf commit 7f65c338fc16cf26b351e83e7c3ec125b74abb02 @freakboy3742 freakboy3742 committed Feb 5, 2011
@@ -31,6 +31,7 @@
}
};
var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS").attr("autocomplete", "off");
+ var nextIndex = parseInt(totalForms.val());
var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").attr("autocomplete", "off");
// only show the add button if we are allowed to add more items,
// note that max_num = None translates to a blank string.
@@ -53,12 +54,12 @@
}
addButton.click(function() {
var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS");
- var nextIndex = parseInt(totalForms.val());
var template = $("#" + options.prefix + "-empty");
var row = template.clone(true);
row.removeClass(options.emptyCssClass)
.addClass(options.formCssClass)
.attr("id", options.prefix + "-" + nextIndex);
+ nextIndex += 1;
row.find("*")
.filter(function() {
var el = $(this);
@@ -94,7 +95,7 @@
// Insert the new form when it has been fully edited
row.insertBefore($(template));
// Update number of total forms
- $(totalForms).val(nextIndex + 1);
+ $(totalForms).val(parseInt(totalForms.val()) + 1);
// Hide add button in case we've hit the max, except we want to add infinitely
if ((maxForms.val() != '') && (maxForms.val()-totalForms.val()) <= 0) {
addButton.parent().hide();

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 7f65c33

Please sign in to comment.