November 2019
Beginner
804 pages
20h 1m
English
This method is very straightforward. We retrieve the form element from the DOM and call reset() on it:
clearNewBookForm(collectionIdentifier: string): void {
if (!collectionIdentifier) {
throw new Error("The collection identifier must be provided!");
}
const newBookForm = document.getElementById (`newBook-${collectionIdentifier}`) as HTMLFormElement;
if (!newBookForm) {
throw new Error(`Could not find the new book form for collection ${collectionIdentifier}`);
}
newBookForm.reset();
}
Let's continue with the removeBook method.
Read now
Unlock full access