Search code examples
javascripttwigslim

How to loop on javascript urlfor() on Slim + Twig


{% block page_scripts %}
<script type="text/javascript">
    $('#dataTable').DataTable({
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "all-users-json",
        "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
            var url = "{{ urlFor('management.user', , {'user': "+aData[1]+"}) }}"; //<-----------
            $('td:eq(0)', nRow).html('<a href="' + url + '">' + aData[0] + '</a>');
        }
    });
</script>
{% endblock %}

Solution

  • Nevermind, I've just use like this, I've added user/

    $('td:eq(0)', nRow).html('<a href="user/' + aData[1] + '">' + aData[0] + '</a>');