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 include javascript in call to linkTo function in volt file

Hello,

I would like to include the below javascript in my linkTo function call in a volt file. It would help submit the current form when the menu item is clicked. Can this be done or should I use plain php. This jQuery code has been suggested in How to submit a form with JavaScript by clicking a link?

onclick="$(this).closest('form').submit();"'

Below is the volt file code where I would like to include it.

<li><?php echo $this->tag->linkto('save', '<span class="glyphicon glyphicon-save"></span> ' . __('Save')); ?></li>

Thanks

You shouldn't use onclick. There is addEventListener or just $(element).on in jquery