r9juia
Last Updated: February 25, 2016
·
5.059K
· mwarkentin
219e6891cd29919cfad373a72eca17dd

Debouncing backbone.js events

Sometimes you might want to debounce (prevent from firing more than once every X milliseconds) the events that you've hooked up to your Backbone views.

events:
  'click #BtnAddIncome': 'addIncome'

addIncome: _.debounce(
  -> @_addTransaction('Income', Data.UncategorizedIncome)
  2000
)
Say Thanks
Respond

2 Responses
Add your response

2413
C7ab2bdfc74f4f7243e81206862ef966

thats interesting, I like that technique. I've been hacking it by adding a flag and manually unflaging after with timeouts.

over 1 year ago ·
7606
0e631d686b8356102da3721bd8cd65c4

Nice tip! The thing that stinks about doing these kind of decorations in Coffee is that they don't work with the fat arrow. That's not a problem with the events map, obviously, but still—I wish there were a nice way to wrap fat arrow methods in general.

over 1 year ago ·