Skip to content

@sukima /infinite-jquery-event-loop.js
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(function($) {
var myTest;
function Test() {
$(Test).trigger("init.test");
}
Test.prototype.ready = function() {
$(this).trigger("ready.test");
};
$(Test).on("init", function() { console.log("Test init'ed"); });
myTest = new Test();
$(myTest).on("ready", function() { console.log("Test ready'ed"); });
myTest.ready();
})(jQuery);
@sukima
Owner

This causes an infinate loop because when you call $(Test) it sees Test as a function and adds it to the document.ready event which is triggered and executed over and over and over and over and...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.