refactor javascript in grid.html.twig