Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setSearch: function(event) {
- var timer = window.setTimeout( function() {
- // run function here
- alert('fired');
- }, 500);
- },
- setSearch: function(event) {
- var self = this;
- if(self.timer)
- clearTimeout(self.timer);
- self.timer = setTimeout(function() {
- alert('fired');
- self.timer = null;
- }, 500);
- }
- setSearch: _.throttle(function() {
- //Do Stuff
- }, 500),
- setSearch: function( ) {
- var firedRecently = false;
- return function(event) {
- if (firedRecently) {
- // it has fired recently. Do you want to do something here?
- } else {
- // not fired recently
- firedRecently = true;
- // run your function here
- alert('fired');
- var resetStatus = window.setTimeout( function () {
- firedRecently = false;
- }, 500);
- }
- }
- }( );
Add Comment
Please, Sign In to add comment