Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJohnny Garces
Courses Plus Student 8,551 PointsWhy was the second parameter not called in bindTasksEvents?
When bindTasksEvents was called for all list-items in incompleteTasksHolder, why was the second parameter (tasksCompleted) not called with the parentheses? I saw Chalkers passed a reference to the taskCompleted function but it was not called. Here's how bindTasksEvent was called:
bindTaskEvent(incompleteTasksHolder.children[i], tasksCompleted);
2 Answers
Steven Parker
231,271 PointsThat second argument is a callback function. You don't want to call it right now, but you want the event handler to call it later.
If you put parentheses after the name, it would get called right now. But by passing the name only, it will just be saved now and called when the event actually happens.
This should become clear in a later video when the bindTaskEvent function is completed.
Christopher Nowack
2,468 PointsThe second parameter doesn't get implemented until there is an event that triggers it, ie. page load/mouse click/refresh etc. When you set up that event handler, it will call that method to be used when you specify an event for it.
Johnny Garces
Courses Plus Student 8,551 PointsJohnny Garces
Courses Plus Student 8,551 Pointsthank you! I'll read up on callbacks.