Skip to content

Instantly share code, notes, and snippets.

@sukima
Last active December 14, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sukima/5013173 to your computer and use it in GitHub Desktop.
Save sukima/5013173 to your computer and use it in GitHub Desktop.
(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
Copy link
Author

sukima commented Feb 22, 2013

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