diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js
index 889e1a5dfc..3b1f31bd23 100644
--- a/django/contrib/admin/static/admin/js/collapse.js
+++ b/django/contrib/admin/static/admin/js/collapse.js
@@ -10,15 +10,15 @@
}
});
// Add toggle to anchor tag
- $("fieldset.collapse a.collapse-toggle").toggle(
- function() { // Show
+ $("fieldset.collapse a.collapse-toggle").click(function(ev) {
+ if ($(this).closest("fieldset").hasClass("collapsed")) {
+ // Show
$(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]);
- return false;
- },
- function() { // Hide
+ } else {
+ // Hide
$(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]);
- return false;
}
- );
+ return false;
+ });
});
})(django.jQuery);
diff --git a/django/contrib/admin/static/admin/js/collapse.min.js b/django/contrib/admin/static/admin/js/collapse.min.js
index 5bf26ec104..b32fbc3472 100644
--- a/django/contrib/admin/static/admin/js/collapse.min.js
+++ b/django/contrib/admin/static/admin/js/collapse.min.js
@@ -1,2 +1,2 @@
-(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){a(b).find("div.errors").length==0&&a(b).addClass("collapsed").find("h2").first().append(' ('+gettext("Show")+")")});a("fieldset.collapse a.collapse-toggle").toggle(function(){a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]);return false},function(){a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset",
-[a(this).attr("id")]);return false})})})(django.jQuery);
+(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){0==a(b).find("div.errors").length&&a(b).addClass("collapsed").find("h2").first().append(' ('+gettext("Show")+")")});a("fieldset.collapse a.collapse-toggle").click(function(){a(this).closest("fieldset").hasClass("collapsed")?a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]):a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset",
+[a(this).attr("id")]);return!1})})})(django.jQuery);