Skip to content

Instantly share code, notes, and snippets.

@jjdelc
Created May 22, 2011 08:56
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jjdelc/985283 to your computer and use it in GitHub Desktop.
Collapse list_filter in Django admin
;(function($){
ListFilterCollapsePrototype = {
bindToggle: function(){
var that = this;
this.$filterEl.click(function(){
that.$filterList.slideToggle();
});
},
init: function(filterEl) {
this.$filterEl = $(filterEl).css('cursor', 'pointer');
this.$filterList = this.$filterEl.next('ul').hide();
this.bindToggle();
}
}
function ListFilterCollapse(filterEl) {
this.init(filterEl);
}
ListFilterCollapse.prototype = ListFilterCollapsePrototype;
$(document).ready(function(){
$('#changelist-filter').children('h3').each(function(){
var collapser = new ListFilterCollapse(this);
});
});
})(django.jQuery);
@peppelinux
Copy link

I wrote a snippets for menu collapse and single element menu collapse.

It's a fork from abyx code, I've just extended it.

If a filter was previously activated the element menu related to this will start as opened.

The filter menu starts closed as default.

https://github.com/peppelinux/Django-snippets/tree/master/django-admin.js-snippets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment