Hello all,
I’m reviving this subject because to me it throws:
'NoneType' object has no attribute 'call_js'
I copy pasted your example:
Is this function defunct?
Is there another way to call JS from client? From server?
Thanks
Hello all,
I’m reviving this subject because to me it throws:
'NoneType' object has no attribute 'call_js'
I copy pasted your example:
Is this function defunct?
Is there another way to call JS from client? From server?
Thanks
You can’t call call_js from the server (since there’ no browser there). If you want to use cal_js, I would:
import anvil.js
anvil.js.call_js(<JS Fnction Name>)
Your get_open_form
is returning None.
In your case, where you want to call Javascript from a module where there may or may not be an open form yet, use the anvil.js
method: Anvil Docs | JavaScript
Hi @phm,
The reason this thread contains a few different answers is that the tools for using Javascript from Anvil have got steadily better since this thread was started back in 2019! All these methods still work, with some caveats (eg, as @jshaffstall points out get_open_form()
returns None
until the first form has finished initialising) – but here’s how to do what you want in the most modern, simplest, easiest way:
Just replace the code of your Form1.Module1
with:
from anvil.js.window import testing
def show_alert():
testing()
Yes, that code is as simple as it looks. You defined a JS function called testing
, then you imported it into your Python code, and called it!
Thank you all!
Yeah, it was 2019, pre-pandemic times (when we were hopeful and candid). I’m just kidding.
How an uplink server module could call a NodeJS function? Like puppeteer for instance.
Please someone let me know about server call to JS script
If you have a new question you should probably start a new post, completing a new Q+A template.
I’d first suggest searching the internet for
How to call NodeJs from Python
There’s lots of information out there that you might want to try first before asking the forum.
Please note @stucork that it was in my OP.
I searchd Google before asking but I get that I’ll have to find out by myself.