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 trialammarkhan
Front End Web Development Techdegree Student 21,661 PointsCannot understand the inside of function
While i follow that function is javascript for
but i cannot understand the inside of function e.g javascript blindTaskEvents(incompleteTaskHolder.childern[i], taskCompleted);
Can someone explain to me what is going on inside the function body?
john larson
16,594 PointsI can't, but I re-posted it so it would be easier to see. Also you have "blindTaskEvents(incompleteTaskHolder.childern[i], " and it should be "bind" not "blind" that might cause a problem at some point
john larson
16,594 PointsAmmar, I noticed your into php. What do you think of php compared to JavaScript?
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsJohn Larson I think both are good, whichever lands me a job.
john larson
16,594 Points"Thanks, but like my thread says, i wanted to know the inside of function."... to be clear are you asking about the for loop? or the function
blindTaskEvents(incompleteTaskHolder.childern[i], taskCompleted);
that is referenced here?
3 Answers
Kevin Korte
28,149 PointsHey, check this one out: https://teamtreehouse.com/community/bindtaskevents
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsKevin Korte Thanks, but like my thread says, i wanted to know the inside of function.
Joel Kraft
Treehouse Guest TeacherAmmar Khan, as of this video, the function bindTaskEvents
has not yet been written. We are just looping over all the children of the ul and executing bindTaskEvents
on them as if it were already written. In the next video(s) that function will be written and explained.
Does that answer your question?
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsI suppose, but i hope i get grasp on what is happening inside.
Joel Kraft
Treehouse Guest TeacherSorry! I hadn't realized you'd already reviewed the next video. The bindTaskEvents
function is responsible for getting references to three children inside each task element (the checkbox and the two buttons), and putting event handlers on them. In other words, once bindTaskEvents
has done its work, each task's edit and delete button will be able to respond to a user's mouse clicks, and the checkbox will respond to being selected and unselected.
First, bindTaskEvents
locates the elements using the querySelector
method, and stores each element in a variable. Then, it binds each element to a function that will run every time a user interacts with that element. In the case of the editButton
element, for example, every time a user clicks on that, the function editTask
will run. editTask
is also known as a callback function, and it defines behavior for the editButton
element on the page.
john larson
16,594 PointsJoel, Thank you for your comment about the function: "We are just looping over all the children of the ul and executing bindTaskEvents on them as if it were already written". Because to me part of what made this particular course hard to follow was just that. Andrew had things in his mind he was going to do (brilliant people do that kind of stuff) coded them out and by the time he got to them [next video] I am so hopelessly lost that **** if I know whats going on.
Joel Kraft
Treehouse Guest TeacherJohn, I understand your frustration! There are a lot of moving parts here, and we're doing our best to present them in the order that makes the most sense. We're also constantly working to improve them, and appreciate your feedback, which helps us in that regard.
This stuff isn't easy, but I hope you will stick with it! It can be rewarding once you get the hang of it. Keep asking questions in the forums if you get stuck, and, of course practice coding as much as you can!
john larson
16,594 PointsJoel, thanks for your response. I am less than amused at my own inability to grasp this course. I'm just now realizing the breadth of what is being taught here. Right now I am just going through the code line by line not moving on to anything else till I really get it.
Joel Kraft
Treehouse Guest TeacherAmmar Khan, did that explanation help? Do you have other questions I can help with?
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsJohn Larson I am with you, while i was quickly able to get andrew course on sql and jQuery in the time it was suppose to but i am unable to grasp this course and it make my head hurt. I think the key element missing here is andrew should have broken it more down, showing what happen after every function, instead of just writing everything down and running it in one video (that is my opinion)
john larson
16,594 Pointsjohn larson
16,594 Points