Answers.Body: <p>You can listen to the add button's <code>click</code> event like so:</p>
  
  <pre><code>$('.matrix &gt; .buttons &gt; .add').on('click', function(e) {
      // your js
  });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-21T14:27:25.647Z
Answers.LastActivityDate: 2015-06-21T14:27:25.647Z
Answers.UserDisplayName: Bob Olde Hampsink
Body: <p>I'm trying to call the addBlock function from the Matrix fieldtype. Whenever a block is added i need to run some basic javascript. 
  Does anyone have an idea how to go about this?
  thanks!</p>
  
Tags: <plugin-development><matrix>
Title: Extending the matrixinput class
ThreadText: # Extending the matrixinput class
  
  (Asked by: username_0 on 2014-10-23)
  
  I'm trying to call the addBlock function from the Matrix fieldtype. Whenever a block is added i need to run some basic javascript.
  Does anyone have an idea how to go about this?
  thanks!
  
  **Tags:** plugin-development, matrix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-21. Score: 2
  
  You can listen to the add button's `click` event like so:
  
  ```
  $('.matrix > .buttons > .add').on('click', function(e) {
      // your js
  });
  
  ```
  
  
  ---
  
  