-
-
Save AyumuKasuga/cfab07a0c1953229658f to your computer and use it in GitHub Desktop.
Collapse list_filter in Django admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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