Skip to content

Instantly share code, notes, and snippets.

@roy
Created February 3, 2011 09:48
Show Gist options
  • Save roy/809280 to your computer and use it in GitHub Desktop.
Save roy/809280 to your computer and use it in GitHub Desktop.
Correct way of doing initializing one instance
var TestClass = Class.create({
initialize: function(){
//fancy stuff here
}
});
document.observe("dom:loaded", function(){ new TestClass(); });
// or
(function(){
var TestClass = Class.create({
initialize: function(){
//fancy stuff here
}
});
new TestClass();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment