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 Webpages with Javascript Uncaught ReferenceError: checkboxEventHandler is not defined

Does anyone know where the checkboxEventHandler function or variable is defined? I am having trouble keeping up with Chalkers on this one. He moves just a tad fast for me.

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,254 Points

Hi Eric,

Actually I'm looking at this one again for a third time through there course! :)

Try looking at your bindTaskEvents function where the checkBoxEventHandler is passed in as a parameter.

When you try to it as a reference when you trigger an event, the reference must be exactly the same.

var bindTaskEvents = function(taskListItem, checkBoxEventHandler) {
    console.log("Bind list item events...");
    //select taskListItem's children    
    var checkBox = taskListItem.querySelector("input[type=checkbox]");
    var editButton = taskListItem.querySelector("button.edit");
    var deleteButton = taskListItem.querySelector("button.delete");  

    //bind editTask to edit button
    editButton.onclick = editTask;

    //bind deleteTask to delete button
    deleteButton.onclick = deleteTask;

    //bind checkBoxEventHandler to checkbox
    checkBox.onchange = checkBoxEventHandler;  

Failing that, add your code to the forum and we can have a closer look. :)

Thanks!

I was using a different case for the parameter as for the onchange event in the function. One had a capital B, the other didn't. I did not know this could create a reference error. Would normally let it autocomplete the parameter but I think this only works for functions in the workspace.

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,254 Points

Hmmm it should pick it up but never mind. One thing about Autocomplete is you still have to be aware of which is the right one to fill in . :)