Closed evangdesigns closed 4 years ago
Add button to domString
inside printEnvironments
<button type="link" class="btn btn-link delete-environment" id="delete-${environment.id}">DELETE</button>
Add Event listener to the end of the printEnvironments()
function
$('#environments').on('click', '.delete-environment', deleteEnvironment;
**Delete Function for environments.js
const deleteEnvironment= (e) => {
e.stopImmediatePropagation();
const enviId = e.target.id.split('delete-')[1];
environments.deleteBoard(enviId)
.then(() => {
enviData.getEnvis(enviId)
});
firebase.auth().onAuthStateChanged((user) => {
// eslint-disable-next-line no-use-before-define
printEnvironments();
});
})
.catch((error) => console.error(error));
};
Axios call to add to environmentsData.js
const deleteEnvironment = (Id) => axios.delete(`${baseUrl}/environments/${id}.json`);
USER STORY As a user, I should be able to delete an environmental reading.
AC WHEN I am on the environments page I should see a delete link on the far right for each row of each environment. AND when I click
DELETE
THEN it will delete that environment from the database.DEV
DELETE
Button (link) and event listener to theprintEnvironments()
function inenvironments.js
environments.js
axios
delete call toenvironmentsData.js