listenTo - can't specify context for the callback #1946

AjaxSolutions opened this Issue Dec 14, 2012 · 5 comments


None yet

5 participants


Would you say context param should be added?

listenTo: function(object, events, callback) {


Nope. The whole idea with listenTo is that the object you're calling it from is the context.

view.listenTo(model, 'change', ...)

view is the context.

@jashkenas jashkenas closed this Dec 14, 2012

Why not adding an optional context? It would definately speed up things for this kind of callbacks :

view.listenTo(object,'some events',this.$,this.$el)

Instead of having to write manually trivial functions on the view that will just delegate to the exact same jQuery method on $el. What do you think?


Maybe, view.listenTo(object, 'some events', _.bind(this.$, this.$el)); ?


Using the same context means events can easily be removed and cleaned up when the view is destroyed. Having another context would mean this wouldn't happen and you'd need to manually clean up the events like with on


Yeah ok it makes more sense the way it is and @tbranyen solution is perfect, ty!

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