-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
Javascript gets unloaded after remi reloads with "handshake complete" #523
Comments
To fix this, you can delay the execution of the JavaScript code until the page is fully loaded using the window.onload event. Here's how you can modify your custom.js:
By using window.onload, you ensure that the JavaScript code will only execute after the entire page, including all its resources (like images and stylesheets), has finished loading. Additionally, there's a syntax error in your main.py code. You need to close the gui.Label constructor with an extra closing parenthesis. Here's the corrected line:
|
Thanks for the answer. The closing parenthesis is already in the original code. I know that I can use the onload callback. Remember, this is about a real external library, but nobody would read my bug report if I submit hundreds of code lines with additional external libraries, hence the minimal example. In reality I need to load an external file. In any case, the solution must depend on external javascript files, not inline code. |
Hello @diovudau , Your example loads correctly the js library. You can inspect your page to check it is structured correctly. However I suggest every time to not to use JS external libraries if the same job can be done with python. Kind Regards |
Here is the code for two simple files, "main.py" and "custom.js", living in the same directory.
The purpose is to simulate loading of a 3rd party javascript library. In this example it simply rewrites the
innerHTML
of a<div>
to "Hello World".However, I cannot get Remi to permanently make it work. What happens is that briefly on load/refresh the javascript is executed and "hello world" appears on the page, but Remi triggers some kind of second loading, indicated with
handshake complete
in the terminal, which makes "hello world" disappear.I would expect such a simple, everyday usecase of html and javascript to work.
I am looking forward to comments and explanations.
Here is the code:
main.py
custom.js
The text was updated successfully, but these errors were encountered: