Skip to content

Instantly share code, notes, and snippets.

@dre3s
Last active January 12, 2016 17:49
Show Gist options
  • Select an option

  • Save dre3s/3130cffe1dbb12f5634c to your computer and use it in GitHub Desktop.

Select an option

Save dre3s/3130cffe1dbb12f5634c to your computer and use it in GitHub Desktop.
my.js.backbone.delegateEvents

#Controling Events with DelegateEvents

In Backbone Views

 events: {
	'click .gallery-right-arrow-wrap' : 'loadMore',
	'click .gallery-left-arrow-wrap' : 'loadLess',
	'click .about-video-item-wrap' : 'callVideo'
  },
  eventsOff: function(unbind) {
    this.delegateEvents(_(this.events).omit(unbind));
  },
  eventsOn: function(bind) {
    this.delegateEvents(_(this.events).defaults(bind));
  }
  //unbind
  this.eventsOff('click .gallery-left-arrow-wrap');
  //bind
  this.eventsOn('click .gallery-left-arrow-wrap');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment