Created
December 2, 2011 16:46
-
-
Save stubotnik/1423920 to your computer and use it in GitHub Desktop.
pre-onComplete handler for all Ajax requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xAjaxRequest = Class.create({ | |
initialize: function (url, options) { | |
//if the request has a callback, wrap that in our own callback | |
if (typeof options.onComplete == "function") { | |
var f = options.onComplete; | |
options.onComplete = | |
function(r) { | |
if (this.preOnComplete(r)) { | |
f(r); | |
} | |
}.bind(this); | |
} | |
new Ajax.Request(url, options); | |
}, | |
preOnComplete: function(r) { | |
console.log("I fire before all onComplete callbacks"); | |
return true; //or return false to prevent callback from going ahead | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment