Feedback: Exploring Service - Mocking Quick File Server (2)
When following the course LFW111 in chapte Exploring Service - Mocking Quick File Server (2) i think i found some mistakes:
Files are referred to as Folder's:
The second step is to create two files inside the static folder labeled index.html and app.js. Place the respective code into each file as shown below:
---------------------------------------------------------------------------
index.html Folder:
---------------------------------------------------------------------------
<html>
<head>
I think it should say: index.html File: instead of index.html Folder:. Be aware that this is also the case for app.js Folder: should become app.js File: to avoid confusion.
Not waiting for DOMContentLoaded event results in not finding the fetch button
When creating a new file server using the static npm package. Some JavaScript is added. But because the DOM is not loaded, the button with id fetch cannot be found. An event listener should be added to wait for the DOM content to be loaded. Something like so:
addEventListener("DOMContentLoaded", () => {
document.getElementById("fetch").addEventListener("click", async () => {
await populateProducts();
});
});
Comments
-
But because the DOM is not loaded, the button with id
fetchcannot be found. An event listener should be added to wait for the DOM content to be loaded. Something like so:addEventListener("DOMContentLoaded", () => { document.getElementById("fetch").addEventListener("click", async () => { await populateProducts(); }); });Hi,
As I understand it, js-modules which are loaded as<script type="module">
are deferred and what that means is that those modules are executed right before
DOMContentLoadedevent is fired and after document is completely parsed, so there should not be any danger that some elements are not present in the DOM.The DOMContentLoaded event fires when the HTML document has been completely parsed, and all deferred scripts (
<script defer src="…"> and <script type="module">) have downloaded and executed. It doesn't wait for other things like images, subframes, and async scripts to finish loading.https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event
0
Categories
- All Categories
- 177 LFX Mentorship
- 177 LFX Mentorship: Linux Kernel
- 750 Linux Foundation IT Professional Programs
- 373 Cloud Engineer IT Professional Program
- 169 Advanced Cloud Engineer IT Professional Program
- 74 DevOps IT Professional Program - Discontinued
- 4 DevOps & GitOps IT Professional Program
- 99 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 1 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 4 Cloud & Containers Training
- 1 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 1 Networking Training
- 2 Open Source Best Practice Training
- 1 System Administration Training
- 1 System Engineering Training
- 1 Web & Application Development Training
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 769 Linux Distributions
- 81 Debian
- 68 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 106 Mobile Computing
- 18 Android
- 73 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 955 Programming and Development
- 310 Kernel Development
- 627 Software Development
- 984 Software
- 376 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
- 1.4K LFS258 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)