I just ran across this gotcha recently. When in Javascript code you can use anvil.call
to call back to Python code. The first parameter to anvil.call
is a DOM node. That can be a DOM node on a form, and it’ll work its way back up to the form to make the Python call there.
The problem comes when one of the components is a Custom HTML component. It’s recognized as the enclosing form and the Python function is called on it instead of on the actual enclosing form.
I ran into this when I switched one of my custom components from blank panel to custom HTML, and all of a sudden the Javascript calls were targeting it instead of the enclosing form.
I don’t know if this is expected behavior or not, but I certainly didn’t expect it, so figured this might help someone else.
Here’s a clone that shows the behavior: Anvil | Login
The clone has a blank panel container and a custom HTML container, both of which contain an embedded component that calls the same Javascript function.