Giter Club home page Giter Club logo

Comments (3)

momostafas avatar momostafas commented on July 27, 2024

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.

diovudau avatar diovudau commented on July 27, 2024

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.

dddomodossola avatar dddomodossola commented on July 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.