Reputation: 17434
I have the next code
{%- if my_page.title -%}
<a class="page-link" onclick="return smoothlyScrollToSection()">{{ my_page.title | escape }}</a>
{%- endif -%}
smoothlyScrollToSection
defined before in code. It works fine.
I want to pass my_page.title
as a parameter to smoothlyScrollToSection
. Is there a way to do it?
<a class="page-link"
onclick="return smoothlyScrollToSection({{my_page.title}})">
{{ my_page.title | escape }}</a>
Doesn't work
Upvotes: 2
Views: 1777
Reputation: 12610
You forgot the single quotes...
<a class="page-link"
onclick="return smoothlyScrollToSection('{{my_page.title}}')">
{{ my_page.title | escape }}
</a>
It is a string and you should let Javascript know.
Upvotes: 1