Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ejs <%= not working #557

Open
rtregrogan opened this issue Dec 1, 2020 · 2 comments
Open

ejs <%= not working #557

rtregrogan opened this issue Dec 1, 2020 · 2 comments

Comments

@rtregrogan
Copy link

Hi,

I am trying to implement inline delete on a table using a modal. Here is my code.

<% for (let ta of task) { %>

<%= ta.taskID %>
<%= ta.taskName %>
<%= ta.taskType %>


Delete







Are you sure you want to delete <%= ta.taskName %>?


×



CONFIRM DELETE




<% } %>


here is my route:

app.delete('/managetask/:id', async (req, res) => {
const { id } = req.params;
// await Task.findOneAndDelete(id);
console.log(id);
res.redirect('/managetask');
});

I tried logging the id and it is showing the id of the first item on the table instead of the actual item am trying to delete.

please help!

@nichtich
Copy link

Can you put your code snippets in Markdown code blocks?

@caleberi
Copy link

app.delete('/managetask/:id', async (req, res) => {
const { id } = req.params;
// await Task.findOneAndDelete(id);
console.log(id);
res.redirect('/managetask');
});

from the above snippet you got the id from the request parameter and performed a delete operation . It is correct but for the view i think you should ensure you pass the right id to the "/managetask" route after clicking the button on the modal . The redirect url will show the update after deletion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants