Skip to content

Instantly share code, notes, and snippets.

@xaviershay
Forked from juliocesar/gist:41145
Created December 29, 2008 02:49
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 xaviershay/41148 to your computer and use it in GitHub Desktop.
Save xaviershay/41148 to your computer and use it in GitHub Desktop.
// Original
(function($) {
$.stuff = function(bitoftext) {
$.stuff.report = function() { console.log(bitoftext) };
}
$.stuff.report = function() {
throw("Constructor not called!");
}
})(jQuery);
// So you can go
// $.stuff("var i'm passing to the constructor")
// $.stuff.report()
// What you probably want
(function($) {
$.stuff = function(bitoftext) {
return {
report: function() { console.log(bitoftext) }
};
}
})(jQuery);
// So you can go
// myobj = $.stuff("var i'm passing to the constructor")
// myobj.report()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment