We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to call js function in volt?

How to call js function in volt?..when i am trying call a js function like progress(id) ,the function is working but in the view the whole method was printing...

Volt is just template engine, you can not call js from Volt in a general sense. You can add tag <script> for executing some js code in browser:

...
<script>
    progress(id);
</script>
...

Thank you..but i am not able to pass variables of volt to js function, iam able to variable on view but i am not able to send it to the js function as a parameter.....like progress (files.id)...Can you help?

progress({{files.id}})

JS is frontend, volt is backend, those are totally diffrent things.

edited Feb '17

Think of volt as of general php (because it's rendered to php prior to processing requests).When I need to use a value from php var in js, and to avoid inline js, I usually put it in a hidden element on a page, than I get this element and use it's value in javascript as I need. Otherwise Wojciech's answer is a way to do.