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

How to Pass Variables to a Component's JavaScript Code #757

Closed
m-m-moradi opened this issue Nov 18, 2024 · 2 comments
Closed

How to Pass Variables to a Component's JavaScript Code #757

m-m-moradi opened this issue Nov 18, 2024 · 2 comments

Comments

@m-m-moradi
Copy link

Hi,
I have a use case where I need to provide variables, specifically URLs generated using the url tag with arguments, to a component's JavaScript code for AJAX requests.

I came across #744 on how to provide data to HTML templates and also read #622, but the later left me more confused. Additionally, I found an interesting blog post on safely passing data to JavaScript in Django templates. However, I still don’t understand the best way to provide variables to a component's JavaScript code with this package.

While I understand that I could embed the variables in HTML (e.g., using data-* attributes) and retrieve them with JavaScript, I am curious if there is a supported or recommended approach within the package's capabilities to achieve this.

Thanks for your help!

@JuroOravec
Copy link
Collaborator

Hi @m-m-moradi, for now I recommend to go with the data-* HTML attributes or similar. Support for this is in the pipeline, I've got the feature working locally, but it still needs polishing, tests, and documentation. Could be still maybe a month away.

@m-m-moradi
Copy link
Author

I appreciate that.

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