Answers.Body: <p>The Craft.MatrixInput class that manages each Matrix field doesn’t actually get assigned to a variable, so there’s no way to reference it right now. We probably won’t change that, since there wouldn’t be much point to it in the first place. The class doesn’t provide any sort of object-oriented API for managing the blocks; there’s no need for it in the current implementation.</p>
  
  <p>If you want to get a reference to all the blocks’ containers, you can just use a jQuery selector:</p>
  
  <pre class="lang-js prettyprint-override"><code>var $blocks = $('#fields-myMatrixField &gt; .blocks &gt; div');
  
  $blocks.each(function() {
      var $block = $(this),
          id = $block.data('id');
      // ...
  });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-18T15:18:08.850Z
Answers.Text: Great. My reason for asking was just to have something that won't break if you change the markup a lot, but I guess it isn't likely you will do that too often.
Answers.UserDisplayName: Fred Carlsen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-18T09:55:32.680Z
Answers.LastActivityDate: 2014-10-18T09:55:32.680Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>Is there a way to use Craft javascript API to fetch all Matrix rows of a specific field on the entry edit page?</p>
  
  <p>If not, could that be added? Would be useful, for example in terms of fetching the handle/id and using that in the frontend to simulate Matrix inside Matrix.</p>
  
Tags: <matrix><javascript>
Title: Fetching Matrix rows with Javascript
ThreadText: # Fetching Matrix rows with Javascript
  
  (Asked by: username_0 on 2014-10-18)
  
  Is there a way to use Craft javascript API to fetch all Matrix rows of a specific field on the entry edit page?
  
  If not, could that be added? Would be useful, for example in terms of fetching the handle/id and using that in the frontend to simulate Matrix inside Matrix.
  
  **Tags:** matrix, javascript
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-18. Score: 1 | Accepted answer
  
  The Craft.MatrixInput class that manages each Matrix field doesn’t actually get assigned to a variable, so there’s no way to reference it right now. We probably won’t change that, since there wouldn’t be much point to it in the first place. The class doesn’t provide any sort of object-oriented API for managing the blocks; there’s no need for it in the current implementation.
  
  If you want to get a reference to all the blocks’ containers, you can just use a jQuery selector:
  
  ```js
  var $blocks = $('#fields-myMatrixField > .blocks > div');
  
  $blocks.each(function() {
      var $block = $(this),
          id = $block.data('id');
      // ...
  });
  
  ```
  
  > **Comments:**
  > **username_0**: Great. My reason for asking was just to have something that won't break if you change the markup a lot, but I guess it isn't likely you will do that too often.  
  
  ---
  
  