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 trial

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perform: Traversing Elements with querySelector

Binding only worked for part.

Help!

Binding only worked for a part.

please see my JSBIN: https://output.jsbin.com/veqoka/

When I click edit task and add it will work, but only for the first set of buttons with "pay bills". All others don't work. :/

Marcus Parsons Tagging you because you are the JS champ! lol

1 Answer

Hey Tony,

I found your problem man! In your bindTaskEvents function, you actually have two different variables for your check box selector. You initialize it as checkbox but then you try to bind the event to checkBox which doesn't exist. All you have to do is rename one to match the other like this:

var bindTaskEvents = function(taskListItem, checkBoxEventHandler){
    console.log("you've binded an event");
        //select taskListItem children
    var checkbox = taskListItem.querySelector("input[type=checkbox]");
    var editButton = taskListItem.querySelector("button.edit");
    var deleteButton = taskListItem.querySelector("button.delete");
        //bind the edit task to edit button
    editButton.onclick = editTask;
    deleteButton.onclick = deleteTask;
        //bind deleteTask to delete button
        //bind checkBoxEventHandler to checkbox
        //changed checkBox to checkbox
    checkbox.onchange = checkBoxEventHandler;
}

oh wow! thanks! So I entered a capital instead of lowercase. Got it.

Don't you love it when it's just something simple but you've stared and stared at the code trying to figure out what's wrong? haha You know it's no problem, man.