File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change 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 →</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 →</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+ }
You can’t perform that action at this time.
0 commit comments