Closed Ankur-Khandelwal closed 2 years ago
If you already declared loveFunc
function, why do you still want to use anonymous function?
You can simply use onclick=<% loveFunc(event) %>
@jkalandarov because without using the anonymous function, the function is getting called even without clicking the button.
@Ankur-Khandelwal did you figure out how to do this ? Im stuck also
@Kalud-Z No, I couldn't.
You're confusing templating and HTML event attributes. You can't call a function in your EJS onclick.
I want to use an arrow function inside an ejs scriplet tag as shown below:
<button type="button" class="loveButton" id="<%= post._id %>" onclick=<% () => loveFunc(event) %> >
However the arrowhead is being interpreted as the closing tag for the ejs tag there.