Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function passed to render cannot be used in element click event attributes onclick. #1341

Open
Previesam opened this issue Feb 20, 2021 · 3 comments

Comments

@Previesam
Copy link

I have passed a function for render and I confirmed the exist by outputting it like a variable however I am not able to use it onclick like so

<button onclick="{{ myFunction(another variable) }}>My Button

@ogonkov
Copy link
Contributor

ogonkov commented Feb 20, 2021

Nunjucks is not responsible for handling JS events.

@Previesam
Copy link
Author

Okay, so I have noticed that all functions passed to the template get executed when the page loads or reload as long as they are called on the page somewhere, and functions cannot be executed using the js event attribute. Actually, this is not what I expected with the function call capability I won't have any need for it unless it can be triggered on js event.

@ogonkov
Copy link
Contributor

ogonkov commented Feb 24, 2021

Template basically is a js, that outputs HTML string you need.

Check your output HTML to debug problem with your event handlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants