Created
June 9, 2011 20:09
-
-
Save abyx/1017597 to your computer and use it in GitHub Desktop.
java script trick to hide the "filter" in a django admin view
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.$filterTitle.click(function(){ | |
that.$filterContent.slideToggle(); | |
that.$list.toggleClass('filtered'); | |
}); | |
}, | |
init: function(filterEl) { | |
this.$filterTitle = $(filterEl).children('h2'); | |
this.$filterContent = $(filterEl).children('h3, ul'); | |
$(this.$filterTitle).css('cursor', 'pointer'); | |
this.$list = $('#changelist'); | |
this.bindToggle(); | |
} | |
} | |
function ListFilterCollapse(filterEl) { | |
this.init(filterEl); | |
} | |
ListFilterCollapse.prototype = ListFilterCollapsePrototype; | |
$(document).ready(function(){ | |
$('#changelist-filter').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.
Hope this helps
https://github.com/peppelinux/Django-snippets/tree/master/django-admin.js-snippets
ps = I love moretti beer too ! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for your job first of all. I say to my self, if there is a way to start the admin view with list filter collapsed already. Thanks in advance