Search code examples
eventsbackbone.jsmarionette

How do I unbind a Marionette's listenTo?


If I listened to an event using .listenTo(), how do I unbind it?

In some code I am working on, I have something like:

class Something extends Marionette.CompositeView

    initialize: ->
        ...
        // listen to an event of a static object 
        @listenTo Something.dateRange, DateRange.EVENT_CHANGED, @_update

The problem appears to be when I switch between views, this event is not unbound, thus, it gets triggered more and more times as the view is reinitalized. Shouldn't Marionette unbind such events? If it doesn't, how do whats the reverse of listenTo? I guess I just put that in onBeforeClose


Solution

  • Oh I think I got it ... its stopListening from Backbone.Events not Marionette. I was looking in the Marionette docs, the wrong place. The relevant information is within the Backbone Events docs.