How to init "$.material.init();" after render template already with Flow Router?

I would like to init $.material.init(); after render template already with Flow Router in layout

<template name="mainLayout">
.................

<script>
        $(document).ready(function () {
            // This command is used to initialize some elements and make them work properly
            $.material.init();
        });
    </script>

But don’t work for Material animate style when I change router “/toAny”.
And then I try to add $.material.init(); at the end of template, It work fine.
Please help me.