I'm new to Backbone and am confused by the difference between the events hash (events {}) and listenTo that you put in the initialize method. Why would you use one over the other. Isn't the events hash set up on initialize?
events
is used for attaching event listeners on DOM elements. Backbone uses event delegation technique for binding the handlers behind the scenes.
listenTo
is used for listening to Backbone related events, and you don't have to use it in the initialize
function's context. For example you can use the listenTo
method of a View object for listening to change
event of a Backbone collection.