Custom button event

Javascript cannot call python functions directly. You can use the anvil.call function from javascript but I will suggest using the anvil.js module for this

Here is how you can do it:

from anvil.js.window import document

document.getElementById('YourBTN').onclick=self.onButtonClick

Of course you can use ClassName, TagName, Query Selector, jQuery etc. to get your dom

2 Likes