Skip to content

Commit c033684

Browse files
committed
#424 Fixed showing and hiding filters
1 parent b8118ce commit c033684

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
/*
2-
* src: http://qaru.site/questions/3688420/trying-to-showhide-the-changelist-filter-in-django-admin
1+
/**
2+
* Add button for show and hide filters in actions menu
3+
* src: http://qaru.site/questions/3688420/trying-to-showhide-the-changelist-filter-in-django-admin
34
*/
45

5-
(function($) {
6-
$(document).ready($ => {
7-
$("tr input.action-select").actions()
8-
$('<div id="show-filters" style="float: right;"><a href="#">Show filters</a></p>').prependTo('div.actions')
9-
$('#changelist-filter h2').html('<a style="color: white;" id="hide-filters" href="#">Filter &rarr;</a>')
6+
window.onload = () => {
7+
(function($) {
8+
$(`
9+
<div id="show-filters" style="float: right">
10+
<a href="#">Show filters</a>
11+
</div>
12+
`).prependTo('div.actions')
13+
$('#changelist-filter h2').html('<a style="color: white;" id="hide-filters" href="#">Filters &rarr;</a>')
1014

1115
$('#show-filters').click(() => {
1216
$('#changelist-filter').show('fast')
1317
$('#changelist').addClass('filtered')
1418
$('#show-filters').hide()
1519
})
1620

17-
$('#hide-filters').click(() => {
18-
$('#changelist-filter').hide('fast')
19-
$('#show-filters').show()
20-
$('#changelist').removeClass('filtered')
21-
})
22-
23-
$('#hide-filters').click();
24-
})
25-
})($)
21+
$('#hide-filters')
22+
.click(() => {
23+
$('#changelist-filter').hide('fast')
24+
$('#show-filters').show()
25+
$('#changelist').removeClass('filtered')
26+
})
27+
.click()
28+
})(django.jQuery)
29+
}

0 commit comments

Comments
 (0)