Skip to content Skip to sidebar Skip to footer

Catch All Events Except In Reset

I wanna catch all events except 'reset'. I've a code like this initialized inside a View. messagesCollection.on 'all', @_handleMessageChanges, @ Right now it works for all events.

Solution 1:

When using all, the first argument is the event. So, you can do

_handleMessageChanges: function(event, ...) {
    if ( event === 'reset' ) return;
} 

See it in action here: http://jsfiddle.net/nxs9q/1

From the docs:

"all" — this special event fires for any triggered event, passing the event name as the first argument.

Post a Comment for "Catch All Events Except In Reset"