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.

1 Answer 1


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:

var $blocks = $('#fields-myMatrixField > .blocks > div');

$blocks.each(function() {
    var $block = $(this),
        id = $block.data('id');
    // ...
  • 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. Oct 18, 2014 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.