Skip to content

Instantly share code, notes, and snippets.

@AyumuKasuga
Forked from jjdelc/list_filter_collapse.js
Last active January 27, 2016 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyumuKasuga/cfab07a0c1953229658f to your computer and use it in GitHub Desktop.
Save AyumuKasuga/cfab07a0c1953229658f 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');
if(this.$filterList.children('li').first().hasClass('selected')){
this.$filterList.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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment