Buttons and JS #7067
-
Is it possible to call a JS file from a button and how could I perform this. For example:
Trying this I noticed that it is not working and is not giving me the expected result. I would like to know what is the correct way to implement this on my page. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The Markdown code you posted produces a link to the JavaScript. It does nothing to execute it. The JavaScript in Material works the same as it would for any website. You can add extra JavaScript to be loaded into your pages with the extra_javascript option. The best thing to do is to register a function that will run once the page is fully loaded and will itself register handlers for events on the buttons as needed. The basics of how to register such a callback are described in the "How to integrate with third-party JavaScript libraries" admonition in the documentation (as linked to above). Hope this helps. |
Beta Was this translation helpful? Give feedback.
The Markdown code you posted produces a link to the JavaScript. It does nothing to execute it. The JavaScript in Material works the same as it would for any website. You can add extra JavaScript to be loaded into your pages with the extra_javascript option.
The best thing to do is to register a function that will run once the page is fully loaded and will itself register handlers for events on the buttons as needed. The basics of how to register such a callback are described in the "How to integrate with third-party JavaScript libraries" admonition in the documentation (as linked to above).
Hope this helps.