Ejemplo n.º 1
1
// delegateEvents adds all the needed event listeners to the Todo view.
func (v *Todo) delegateEvents() {
	view.AddEventListener(v, "click", ".toggle", v.Toggle)
	view.AddEventListener(v, "click", ".destroy", v.Remove)
	view.AddEventListener(v, "dblclick", "label", v.Edit)
	view.AddEventListener(v, "blur", ".edit", v.CommitEdit)
	view.AddEventListener(v, "keypress", ".edit",
		triggerOnKeyCode(enterKey, v.CommitEdit))
	view.AddEventListener(v, "keydown", ".edit",
		triggerOnKeyCode(escapeKey, v.CancelEdit))

}
Ejemplo n.º 2
0
// delegateEvents adds all the needed event listeners to the view.
func (v *App) delegateEvents() {
	v.events = append(v.events,
		view.AddEventListener(v, "keypress", ".new-todo",
			triggerOnKeyCode(enterKey, v.CreateTodo)))
	v.events = append(v.events,
		view.AddEventListener(v, "click", ".clear-completed", v.ClearCompleted))
	v.events = append(v.events,
		view.AddEventListener(v, "click", ".toggle-all", v.ToggleAll))
}
Ejemplo n.º 3
0
func (v *NewPerson) DelegateEvents() {
	view.AddEventListener(v, "submit", "#person-form", v.CreatePerson)
}