Comments (7)
Are you referring to the error that the websocket is not connected yet?
from webui.
ws needs to wait for the connection, and executing it immediately or onload will cause an error
Maybe the later js library can add an event queue and execute it after the ws connection is established.
@hassandraga
from webui.
Sorry - two different errors - yes, with window.onload i'm getting websocket is not connected and with the script at the end of the html doc i'm getting uncaught referenceerror: <function_name> is not defined.
I'm trying to populate the html page with data from a local sqlite database when the app starts - it would be nice if that could happen as quickly as possible - thanks -
from webui.
The second mistake you meet is "Uncaught ReferenceError: webui is not defined at...." right?
This is related to the rendering process of the browser. By default, the inline script in HTML will be executed immediately after the HTML is loaded, but webui.js has not been executed yet, which results in the webui variable not being available in the global scope.
from webui.
you can use defer
for <script>
, note that this is only valid for external js files, and the execution order of these js files maintains their relative order, just like a regular script
from webui.
This is fixed in a commit, it's available in the nightly build.
More info in this discussion.
document.addEventListener('DOMContentLoaded', function() {
// DOM is loaded, and `webui` object should be available.
webui.setEventCallback((e) => {
if (e == webui.event.CONNECTED) {
// Connection to the backend is established
console.log('Connected.');
} else if (e == webui.event.DISCONNECTED) {
// Connection to the backend is lost
console.log('Disconnected.');
}
});
});
from webui.
@jinzhongjia - if using webui.call then yes, webui is not defined -- i was using the function name. i see now that webui isn't loaded until DOMContentLoaded so this all makes sense. i guess there is no way to establish the bridge before before the page/body is loaded...
@AlbertShown - thanks -- i'll check that out. I guess your event listener must fire right after the one referenced above -
from webui.
Related Issues (20)
- Question: Usecase of WebUI HOT 2
- webui_close is useless HOT 3
- How to unbind an event? HOT 6
- Floats HOT 5
- Cannot use WebUI versions > 2.4.1 for V wrapper HOT 8
- add cmake cross build
- Can't run example HOT 3
- Errors compiling minimal example: "undefined reference to pthread_create" and "undefined reference to `dlopen'" (and my fixes) HOT 5
- `set_title` function HOT 3
- `webui_set_root_folder` is broken HOT 3
- Regession with the latest changes HOT 6
- set_profile & CORS HOT 9
- SvelteKit + webui problem HOT 23
- Proposal: Option to bind listener on backend that is handled without spawning a new thread HOT 7
- Frameless windows HOT 3
- Segmentation fault on calls to backend functions HOT 7
- get_float does not work correctly HOT 12
- Fix All Issues
- Fix All Core Bugs
- Build ARM CI with TLS HOT 1
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 webui.