mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-11-16 10:55:21 +01:00
7be6c6536a
Add js click handlers for the web UI buttons added in b1f9c9a6e0a3dce73507e6b60782987ee2459f48 in the esphome repository. Since this change doesn't make the .js file incompatible with esphome versions before the referenced commit I guess there's no need to rename the file to -v2. There are probably better ways to write those click handlers, for example we could have a common function to launch the POST request to a URL that it reads from the button object like this: var button_onclick = function(evt) { const xhr = new XMLHttpRequest(); xhr.open("POST", evt.target.onlick_post_url, true); xhr.send(); }; row.children[2].children[0].addEventListener('click', button_onlick); row.children[2].children[0].onclick_post_url = '/light/' + id.substr(6) + '/toggle'; The only problem with this is that iirc ``evt.target`` is browser-specific. |
||
---|---|---|
.. | ||
.keep | ||
apple-touch-icon.png | ||
browserconfig.xml | ||
changelog-1.9.0.png | ||
changelog-1.10.0.png | ||
changelog-1.11.0.png | ||
changelog-1.12.0.png | ||
changelog-1.13.0.png | ||
changelog-1.14.0.png | ||
custom.css | ||
disqus.js | ||
favicon-16x16.png | ||
favicon-32x32.png | ||
favicon-128x128.png | ||
favicon-192x192.png | ||
favicon-256x256.png | ||
favicon-512x512.png | ||
favicon.ico | ||
mstile-150x150.png | ||
safari-pinned-tab.svg | ||
site.webmanifest | ||
version | ||
webserver-v1.css | ||
webserver-v1.js | ||
webserver-v1.min.css | ||
webserver-v1.min.js |