Admin actions as buttons instead of a menu

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function do_action(action) {
    $('div.actions option[selected]').attr('selected', '');
    $('div.actions option[value='+action+']').attr('selected', 'selected');
    $('div#changelist form').submit();
}

function fix_actions() {
    $('th.action-checkbox-column:first').prepend('select<br />all<br />');
    if ($('div.actions option:gt(0)').length<=8) { // Only do this for short lists.
        $('div.actions').css('border-bottom', '0');
        
        $('div.actions label, div.actions button').hide();
        actions_html='<div id="action_buttons" style="padding: 2px 0 2px 0;">';        
        $('div.actions option:gt(0)').each(function(i) {
            actions_html+='<a href="javascript:void(0);" onclick="do_action(\''+this.value+'\');">'+this.text+'</a>';
        });
        actions_html+='</div>';        
        $('div.actions').append(actions_html);
        $('div.actions').css('font-size', '9px');
        $('div.actions').css('font-weight', 'bold');
        $('div.actions a:link').css('background-color', 'white');
        $('div.actions a:link').css('padding', '2px 3px');
        $('div.actions a:link').css('margin', '1px 2px 1px 0');
        $('div.actions a:link').css('border', '1px outset #efefef');
        $('div.actions a:link').css('text-transform', 'uppercase');
        $('div.actions a:link').css('display', 'block');
        $('div.actions a:link').css('float', 'left');
        $('div.actions a:link').css('white-space', 'nowrap');
        $('div.actions').after('<div style="clear: both;"></div>');
    }
}

More like this

  1. Admin actions as buttons instead of a menu [v2] by itavor 2 years, 4 months ago
  2. Drag and drop admin list items by chrsgrrtt 3 years, 8 months ago
  3. Admin action for a generic "CSV Export" by javinievas 3 years, 2 months ago
  4. simple jquery example by lawgon 6 years ago
  5. Add admin edit form buttons (work with django 1.6) by shoreward 4 months, 1 week ago

Comments

david_bgk (on February 20, 2010):

Looks interesting! Can you provide a screenshot of this feature?

#

andybak (on February 26, 2010):

I could but trying the code would take you less time than it will take me to upload a screenshot ;-)

#

hellboy (on January 11, 2011):

How can I use it in my projects?

{% extends "admin/change_list.html" %} {% block extrahead %} [HTML_REMOVED][HTML_REMOVED] [HTML_REMOVED][HTML_REMOVED] [HTML_REMOVED] [HTML_REMOVED][HTML_REMOVED] {% endblock %}

and?

how to call fix_actions?

#

(Forgotten your password?)