Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add optional context parameter

To set as the context in the resolved callback function
  • Loading branch information...
commit 097a03d44f9c9f180d8ec83739d0d21991d98913 1 parent cdabe8b
@MoonScript authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 jquery.wait.js
View
8 jquery.wait.js
@@ -1,9 +1,11 @@
// Wrap setTimeout in a Deferred
-$.wait = function(delay){
+$.wait = function(delay, context){
var deferred = $.Deferred();
- var timer = setTimeout(deferred.resolve, delay);
+ var timer = setTimeout(function(){
+ deferred.resolveWith(context || deferred);
+ }, delay);
deferred.fail(function(){
clearTimeout(timer);
});
return deferred;
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.