I'm trying to call a function from an external JavaScript file in href with Symfony and Twig.
Here is my JavaScript file pm.js :
function test(id) {
alert(id);
}
And here is my template :
{# templates/pm/pm.html.twig #}
{% extends 'base.html.twig' %}
{% block title %}{{ parent() }} | Private messaging{% endblock %}
{% block body %}
(...)
<a href="javascript:test({{ message.id }});">test</a>
(...)
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('build/js/pm.js') }}"></script>
{% endblock %}
How can I do that? Thanks for help.