Skip to content

Instantly share code, notes, and snippets.

@dejanr
Last active December 25, 2015 12:29
Show Gist options
  • Select an option

  • Save dejanr/6976530 to your computer and use it in GitHub Desktop.

Select an option

Save dejanr/6976530 to your computer and use it in GitHub Desktop.
A clean way to debounce a backbone view events
var Model = Backbone.View.extend({
events: {
'keyup input': 'onKeyUp'
},
onKeyUp: _.debounce(function(e){
var target = $(e.currentTarget);
this.model.set({text: target.val()});
}, 200)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment