Created
June 27, 2011 22:16
-
-
Save parker/1049989 to your computer and use it in GitHub Desktop.
Attempting to hijack the global "io:complete" event so that it's accessible across YUI instances
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
// fetch profile results for any ajax calls done via jQuery | |
$(document).ajaxComplete(function (e, xhr, settings) { | |
if (xhr) { | |
var id = xhr.getResponseHeader('X-MiniProfiler-Id'); | |
if (id) { | |
fetchResults(id); | |
} | |
} | |
}); | |
// fetch profile results for any ajax calls done via YUI3 | |
// CURRENTLY DOESN"T WORK | |
YUI().use("io-base", function (Y) { | |
Y.on("io:complete", function (trxId, xhr, args) { | |
if (xhr) { | |
var id = xhr.getResponseHeader('X-MiniProfiler-Id'); | |
if (id) { | |
if (MiniProfiler) { | |
MiniProfiler.fetchResults(id); | |
} | |
} | |
} | |
}); | |
}); |
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
Y1 = YUI().use("io-base", function(Y1) | |
{ | |
Y1.Global.on("io:complete", function(){ | |
Y1.log(arguments); | |
Y1.log("complete - Y1.Global"); | |
}); | |
Y1.on("io:complete", function(){ | |
Y1.log(arguments); | |
Y1.log("complete - Y1.on"); | |
}); | |
Y1.publish("io:complete", { broadcast: 2} ); | |
}); | |
Y2 = YUI().use("io-base", function(Y2) | |
{ | |
Y2.Global.on("io:complete", function(){ | |
Y2.log(arguments); | |
Y2.log("complete - Y2.Global.on"); | |
}); | |
Y2.on("io:complete", function(){ | |
Y2.log(arguments); | |
Y2.log("complete - Y2.on"); | |
}); | |
}); | |
Y1.io("http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"); | |
/* | |
complete - Y1.on | |
complete - Y1.Global | |
complete - Y2.Global.on | |
*/ | |
Y2.io("http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"); | |
/* | |
complete - Y2.on | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment