-
Notifications
You must be signed in to change notification settings - Fork 730
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
todo-list.js is not working #10
Comments
Yep. The video doesn't mention it but you have to add the todo-list script to the ejs file.
|
Oooh thanks! |
the delete not working!!!! |
the delete list don't work:;;;;!!!! |
@chaabninasser It works, at least for the last 6 video tutorials. Can you please provide more details, or share the code snippet? |
app.js var todoController = require('./controllers/todoController'); var app = express(); app.set('view engine','ejs'); app.use(express.static('./public')); todoController(app); app.listen(3009); $('form').on('submit', function(){
}); $('li').on('click', function(){ }); } var data =[{item:'get something'} , {item:'do something'} , {item:'kick something'}]; var urlencodedParser = bodyParser.urlencoded({ extended: false }); module.exports = function(app) { app.get('/todo', function(req,res){ }); app.post('/todo', urlencodedParser , function(req, res){ data.push(req.body); }); app.delete('/todo/:item', function(req,res){ }); } todo.ejs
My todo List
Add Item
<script
src="https://code.jquery.com/jquery-1.12.3.min.js"
integrity="sha256-aaODHAgvwQW1bFOGXMeX+pC4PZIPsvn2h1sArYOhgXQ="
crossorigin="anonymous"></script>
<script src="/assets/todo-list.js"></script>
} |
and
app.js
var express = require('express');
var todoController = require('./controllers/todoController');
var app = express();
app.set('view engine','ejs');
app.use(express.static('./public'));
todoController(app);
app.listen(3009);
console.log(' You are listening to port 3009');
Le ven. 14 sept. 2018 à 12:53, Liviu Şoşu <[email protected]> a
écrit :
… @chaabninasser <https://github.com/chaabninasser> It works, at least for
the last 6 video tutorials. Can you please provide more details, or share
the code snippet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Am5tY8kuam_3RW-IYHDlk4BqWVU-o80Pks5ua5jDgaJpZM4SoYYw>
.
|
@chaabninasser Your delete controller from todoController.js seems incorrect. You are not deleting anything at all. here is how it should look.
Let me know if now it works. |
I don't watch mongodb in net ninja . Just the 4 part of Todo list in net
ninja
Le sam. 15 sept. 2018 15:11, Liviu Şoşu <[email protected]> a écrit :
… @chaabninasser <https://github.com/chaabninasser> Your delete controller
from todoController.js seems incorrect. You are not deleting anything at
all.
here is how it should look.
app.delete('/todo/:item', function (req, res) {
//delete the requested item from mongodb
Todo.find({item:req.params.item.replace(/\-/g, " ")}).remove(function(err,data){
if(err){
throw err;
}
res.json(data);
});
});
Let me know if now it works.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Am5tY-nW5Jg81Ys2_SlFm2h8H2d_yqRCks5ubQqngaJpZM4SoYYw>
.
|
@chaabninasser Sorry for my late reply! Or you don't know how to enable removing the array from the delete controller? If you need help with this, please let me know and I'll see what I can do for you :-) |
I am having the same problem with the delete. app.delete('/todo/:item', function (req, res) { |
Failed to look up view "todo" in views directory, please how do I solve this problem |
it is probably too late for a reply but here is how i solved it by console.log() ing a lot of times i saw that the data we are getting from the click.event has to many spaces before and after the item
and on the to do controller i added a trim function function myTrim(x) {
that is it. enjoy . |
it turns out that Todo.find({item:req.params.item.replace(/ /g, '-')}).deleteOne((err,data)=>{ |
pls. point out error in my code for todo app by express. delete is not working. pls. tell where is the mistake. todocontroller.js todo.ejs <title>ToDo List</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> <script src="/assets/todo-list.js"></script>
Add
todo-list.ejs
}); app.js style.css input[type="text"] { form { button { ul { li { li:hover { |
Have you linked the ajax code (js script) to the html index page? |
Hello, |
Try this in setting your static folder. |
I have already used this in my app.js file |
Okay. |
Thanks. |
I've followed till the video#34 properly and done as instructed, but whenever now I add a new item I can't see it in the app , also same with the deleting the item from todo list .
I think I forget to add/include the todo-list.js file in the .ejs(views), does it concern to that or not? Please guide
The text was updated successfully, but these errors were encountered: