Answers.Body: <p>I've figured out how I can do it, but it doesn't feel like the best way.</p>
  <p>What I've done is hooked on to the <code>showActionTrigger</code> event, then hidden the button if the <code>source != 'staged'</code></p>
  <pre><code>showActionTriggers: function() {
      this.base();
      if (this.$source.data('key') != 'staged')
      {
          $('#button-id').hide();  
      }
  }
  </code></pre>
  <p>I have a feeling the best way is to build the JS on the element action class, under <code>getTriggerHtml</code>, but this will do for now.</p>
  <p>Slowly getting my head around the CP js </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-05T09:49:34.070Z
Answers.LastActivityDate: 2020-11-05T20:55:24.463Z
Answers.LastEditDate: 2020-11-05T20:55:24.463Z
Answers.UserDisplayName: dmatthams
Body: <p>I have a custom element index with an element action to 'Approve' elements.</p>
  <p>The element index has 'Live' and 'Staged' sources.</p>
  <p>Where/how do I set it to only show this action on the 'staged' source OR just on a selection that contains an element that is not approved (latter probably better).</p>
  <p>I've looked at the existing 'Delete' action and see that this uses a data attribute on the element index items 'data-deletable', how do I inject my own data attribute into the listing i.e. 'date-approvable'?</p>
  
Tags: <plugin-development><elementaction>
Title: Hide/show element actions dependent on tab
ThreadText: # Hide/show element actions dependent on tab
  
  (Asked by: username_0 on 2020-11-04)
  
  I have a custom element index with an element action to 'Approve' elements.
  
  The element index has 'Live' and 'Staged' sources.
  
  Where/how do I set it to only show this action on the 'staged' source OR just on a selection that contains an element that is not approved (latter probably better).
  
  I've looked at the existing 'Delete' action and see that this uses a data attribute on the element index items 'data-deletable', how do I inject my own data attribute into the listing i.e. 'date-approvable'?
  
  **Tags:** plugin-development, elementaction
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-11-05. Score: 1
  
  I've figured out how I can do it, but it doesn't feel like the best way.
  
  What I've done is hooked on to the `showActionTrigger` event, then hidden the button if the `source != 'staged'`
  
  ```
  showActionTriggers: function() {
      this.base();
      if (this.$source.data('key') != 'staged')
      {
          $('#button-id').hide();  
      }
  }
  
  ```
  
  I have a feeling the best way is to build the JS on the element action class, under `getTriggerHtml`, but this will do for now.
  
  Slowly getting my head around the CP js
  
  
  ---
  
  