<p>Indeed there is! You're looking for <a href="https://craftcms.com/docs/plugins/element-actions" rel="nofollow noreferrer"><strong>Element Actions</strong>...</a></p>

<blockquote>
  <p>When you select elements on their index pages, the regular toolbar options get replaced with new ones that will trigger various actions, like batch-deleting all of the selected elements.</p>
  
  <p>That functionality is provided by Element Action classes.</p>
</blockquote>

CC BY-SA 3.0
2017-04-11T07:05:15.273Z
[This commit](https://github.com/boboldehampsink/zipassets/pull/12/files) might be a helpful example for how to execute some lines of JavaScript directly from the `getTriggerHtml` method.
carlcs
CC BY-SA 3.0
2017-04-11T07:39:40.823Z
thanks for that fast answer. Could you please read my edit? I copied the code from pixel and tonic - just to see how it works as a first test but it seems like the file is ignored. Do you see my mistake?
Robin Schambach
CC BY-SA 3.0
2017-04-11T07:41:53.920Z
Did you have a look at the code I posted @anubarak?
carlcs
CC BY-SA 3.0
2017-04-11T07:46:11.410Z
Yes of course, it does not work as well (I changed the pluginhandles to mine) edit: everything else in my plugin works - so its not a general problem
Robin Schambach
CC BY-SA 3.0
2017-04-11T07:53:02.350Z
@anubarak so you have registered the element action in your main plugin class?
carlcs
CC BY-SA 3.0
2017-04-11T07:58:56.207Z
that was it... thank you so much :D I appreciate your help
Robin Schambach
CC BY-SA 3.0
2017-04-11T06:50:41.270Z
2017-04-11T07:10:58.703Z
2017-04-11T07:10:58.703Z
Lindsey D
<p>Please excuse me for the title.. I have no idea how to describe my problem better - if someone knows a better description for this question feel free to edit it.</p>

<p>I made a screenshot to clarify what I want to know.. Is it somehow possible to hook a custom option there?<br>
<a href="https://i.sstatic.net/pbCFP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pbCFP.png" alt="enter image description here"></a></p>

<p>I made an excel export for our customer and I would like to add an "export to excel" button there that sends an ajax request to my controller. Could you please explain me in detail how to do this?</p>

<p>Thank you very much
<br><br>
<strong>Edit</strong><br>
So thanks to your answers I created this test (just to see if I can add something)</p>

<pre><code>&lt;?php

namespace Craft;

class SRExcelExport_ExportElementAction extends BaseElementAction
{
    /**
     * Get element action name.
     *
     * @return string
     */
    public function getName()
    {
        return Craft::t('Export Files');
    }

    public function isDestructive()
    {
        return true;
    }

    public function performAction(ElementCriteriaModel $criteria)
    {
        // Remove all the ingredients from the selected elements
        $elements = $criteria-&gt;find();

        foreach ($elements as $element)
        {
            //do something
        }

        // Success!
        $this-&gt;setMessage(Craft::t('success'));
        return true;
    }

    public function getTriggerHtml()
    {
        $js = 'new Craft.ElementActionTrigger({' .
            'handle: '.JsonHelper::encode($this-&gt;getClassHandle()).', ' .
            'batch: true, ' .
            'validateSelection: function($selectedElements){ return true; }, ' .
            'activate: function($selectedElements){ alert("Made you click"); }' .
            '});';

        craft()-&gt;templates-&gt;includeJs($js);
    }
}
</code></pre>

<p>With the Plugin Handle SRExcelExport with the folder structure<br>
srexcelexport<br>
--elementactions<br>
-----SRExcelExport_ExportElementAction.php<br></p>

<p>But nothing happens, the file is ignored, even a <code>die()</code> in the constructor does nothing. Do I need to do something to "call" the class myself or is there just a stupid error I made? I bet its just an obvious minor error I can't see right now</p>

<plugin-development><events><hook>
How to create custom option/action for backend entry lists
# How to create custom option/action for backend entry lists

(Asked by: username_0 on 2017-04-11)

Please excuse me for the title.. I have no idea how to describe my problem better - if someone knows a better description for this question feel free to edit it.
I made a screenshot to clarify what I want to know.. Is it somehow possible to hook a custom option there?

I made an excel export for our customer and I would like to add an "export to excel" button there that sends an ajax request to my controller. Could you please explain me in detail how to do this?
Thank you very much

Edit
So thanks to your answers I created this test (just to see if I can add something)
find();

        foreach ($elements as $element)
        {
            //do something
        }

        // Success!
        $this->setMessage(Craft::t('success'));
        return true;
    }

    public function getTriggerHtml()
    {
        $js = 'new Craft.ElementActionTrigger({' .
            'handle: '.JsonHelper::encode($this->getClassHandle()).', ' .
            'batch: true, ' .
            'validateSelection: function($selectedElements){ return true; }, ' .
            'activate: function($selectedElements){ alert("Made you click"); }' .
            '});';

        craft()->templates->includeJs($js);
    }
}

With the Plugin Handle SRExcelExport with the folder structure
srexcelexport
--elementactions
-----SRExcelExport_ExportElementAction.php
But nothing happens, the file is ignored, even a die() in the constructor does nothing. Do I need to do something to "call" the class myself or is there just a stupid error I made? I bet its just an obvious minor error I can't see right now

**Tags:** plugin-development, events, hook


---

## 1 answers

### Answer by username_1 on 2017-04-11. Score: 3 | Accepted answer

Indeed there is! You're looking for [**Element Actions**...](https://craftcms.com/docs/plugins/element-actions)

> When you select elements on their index pages, the regular toolbar options get replaced with new ones that will trigger various actions, like batch-deleting all of the selected elements.
>
> That functionality is provided by Element Action classes.

> **Comments:**
> **username_2**: [This commit](https://github.com/boboldehampsink/zipassets/pull/12/files) might be a helpful example for how to execute some lines of JavaScript directly from the `getTriggerHtml` method.  
> **username_0**: thanks for that fast answer. Could you please read my edit? I copied the code from pixel and tonic - just to see how it works as a first test but it seems like the file is ignored. Do you see my mistake?  
> **username_2**: Did you have a look at the code I posted @anubarak?  
> **username_0**: Yes of course, it does not work as well (I changed the pluginhandles to mine) edit: everything else in my plugin works - so its not a general problem  
> **username_2**: @anubarak so you have registered the element action in your main plugin class?  
> **username_0**: that was it... thank you so much :D I appreciate your help  

---

