I am trying to build a workout tracker. I am using two JS files. The main.js is supposed to load content from the second (workoutTracker.js) into to the index.html. However, for some reason the content in not being loaded onto the page. Any suggestions will be appreciated. Please let me know if you need further clarification.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fitness Tracker</title>
<link rel="stylesheet" href="style.css" />
<script href="main.js" type="module"></script>
<script href="workoutTracker.js" type="module"></script>
</head>
<body>
<div id="app">
<!--
<table class="tracker">
<thead>
<tr>
<th>Date</th>
<th>Workout</th>
<th>Duration</th>
<th></th>
</tr>
</thead>
<tbody class="tracker__entries">
<tr class="tracker__row">
<td><input type="date" class="tracker__date" /></td>
<td>
<select type="text" class="tracker__workout">
<option value="walking">Walking</option>
<option value="biking">Biking</option>
<option value="fitness">Fitness</option>
<option value="running">Running</option>
<option value="meditation">Meditation</option>
</select>
</td>
<td>
<input type="number" class="tracker__duration" />
<span class="tracker__text">minutes</span>
</td>
<td>
<button type="button" class="tracker__button">×</button>
</td>
</tr>
</tbody>
<tbody>
<tr class="tracker__row tracker__row--add">
<td colspan="4">
<button class="tracker__add">Add Entry +</button>
</td>
</tr>
</tbody>
</table>
-->
</div>
</body>
</html>
JS (main.js):
import workoutTracker from "./workoutTracker.js";
const app = document.getElementById("app");
new workoutTracker(app);
JS (workoutTracker.js):
export default class workoutTracker {
constructor(root) {
this.root = root;
this.root.insertAdjacentHTML("afterbegin", workoutTracker.html());
this.loadEntries();
this.updateView();
}
static html() {
return `
<table class="tracker">
<thead>
<tr>
<th>Date</th>
<th>Workout</th>
<th>Duration</th>
<th></th>
</tr>
</thead>
<tbody class="tracker__entries">
</tbody>
<tbody>
<tr class="tracker__row tracker__row--add">
<td colspan="4">
<button class="tracker__add">Add Entry +</button>
<!--<span class="tracker__add">Add Entry +</span>-->
</td>
</tr>
</tbody>
</table>
`;
}
}