Skip to content

Instantly share code, notes, and snippets.

@snowmantw
Created September 29, 2015 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snowmantw/8850eca5d51f01ff03f9 to your computer and use it in GitHub Desktop.
Save snowmantw/8850eca5d51f01ff03f9 to your computer and use it in GitHub Desktop.
TodoListManager.prototype.onItemChecked = function(event) {
// Do something when the Todo item is clicked.
var checked = event.target.classList.contains('checked');
var todoId = Number.parseInt(event.target.dataset.todoId, 10);
this._listTodoItem[todoId].checked = checked;
};
TodoListManager.prototype.start = function() {
window.addEventListener('click', this.onItemChecked)
};
@snowmantw
Copy link
Author

Put why the 9th line is wrong in comments.

@CaeserNieh
Copy link

是因為this嗎??

@HanVincent
Copy link

這個this是指Window,但是此處this應該是要指TodoListManager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment