Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-11T07:05:15.273Z
Answers.Text: [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.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-11T07:39:40.823Z
Answers.Text: 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?
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-11T07:41:53.920Z
Answers.Text: Did you have a look at the code I posted @anubarak?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-11T07:46:11.410Z
Answers.Text: 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
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-11T07:53:02.350Z
Answers.Text: @anubarak so you have registered the element action in your main plugin class?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-11T07:58:56.207Z
Answers.Text: that was it... thank you so much :D I appreciate your help
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-11T06:50:41.270Z
Answers.LastActivityDate: 2017-04-11T07:10:58.703Z
Answers.LastEditDate: 2017-04-11T07:10:58.703Z
Answers.UserDisplayName: Lindsey D
Body: <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>
  
Tags: <plugin-development><events><hook>
Title: How to create custom option/action for backend entry lists
ThreadText: # 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?  
  [![enter image description here](https://i.sstatic.net/pbCFP.png)](https://i.sstatic.net/pbCFP.png)
  
  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)
  
  ```
  <?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->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  
  
  ---
  
  