Created
May 22, 2011 08:56
-
-
Save jjdelc/985283 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').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); |
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
hello,I've use the js,and it works well.But if I want this kind of effect:when I refresh my django admin site,the list_filter can collapse while not wide.In which place of the js code should be change.