Admin actions as buttons instead of a menu [v2]

 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
32
33
(function ($) {

    function fix_actions() {
        var container = $('div.actions');

        if (container.find('option').length < 10) {
            container.find('label, button').hide();

            var buttons = $('<div></div>')
                .prependTo(container)
                .css('display', 'inline')
                .addClass('class', 'action-buttons');

            container.find('option:gt(0)').each(function () {
                $('<button>')
                    .appendTo(buttons)
                    .attr('name', this.value)
                    .addClass('button')
                    .text(this.text)
                    .click(function () {
                        container.find('select')
                            .find(':selected').attr('selected', '').end()
                            .find('[value=' + this.name + ']').attr('selected', 'selected');
                        $('#changelist-form button[name="index"]').click();
                    });
            });
        }
    };

    $(function () {
        fix_actions();
    });
})(django.jQuery);

More like this

  1. Improved Button Admin by kunitoki 2 years, 2 months ago
  2. Generic admin action export selected rows to excel by jordic 2 years, 6 months ago
  3. Generic admin action export selected rows to excel by aemb87 1 year, 5 months ago
  4. Generic CSV export admin action factory by anentropic 3 years, 11 months ago
  5. Generic CSV export admin action factory with labels by losttrekker 2 years, 1 month ago

Comments

(Forgotten your password?)