Comments (3)
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:
window.onload = function() { document.getElementById("mywidget").innerHTML = "Hello World"; };
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:
self.label = gui.Label("Below this should be the text: 'Hello World'." "It will disappear after the page is fully loaded," "with the handshake. Maybe it will show again for a short while after F5 refresh.")
from remi.
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.
And iirc when I tried the onload route the text was indeed there after a full reload, but then when switching the root widget for "pagination" it disappeared. So the outcome was equally bad.
In any case, the solution must depend on external javascript files, not inline code.
from remi.
Hello @diovudau ,
Your example loads correctly the js library. You can inspect your page to check it is structured correctly.
As @momostafas correctly suggests, you should execute it on a specific event (onload should be fine, or eventually onpageshow).
About pagination, remi dynamically updates page elements. You should eventually trigger the JS execution when page gets updated.
However I suggest every time to not to use JS external libraries if the same job can be done with python.
Kind Regards
from remi.
Related Issues (20)
- got an unexpected keyword argument 'websocket_port HOT 1
- Blank window on standalone_app.py HOT 2
- Labels do not display the correct number of whitespace HOT 1
- [QUESTION] any example of long-polling implementation in remi? HOT 1
- Get selected text from TextInput HOT 6
- automatic scroll down in text widget (write only) HOT 9
- highlight of table cells in front end. HOT 1
- GenericDialog confirm by Enter key pressing HOT 1
- 2 bugs remain for python 3.10 HOT 1
- How to add a radiobox or radiogroup in remi? HOT 1
- How to insert custom HTML
- Add a button that opens a link HOT 2
- Feature request: Allow setting button labels on GenericDialog
- Editor: export do not work correctlly HOT 1
- Termux Version?
- Offline Plotly HTML Integration HOT 1
- Editor directory conflicts with other packages
- [Question] How can I find all the local partitions when working with gui.FileSelectionDialog widget? HOT 3
- Race condition when building single instance App gui
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remi.