Skip to content

Instantly share code, notes, and snippets.

@remino
Created January 5, 2012 05:46
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 remino/1563906 to your computer and use it in GitHub Desktop.
Save remino/1563906 to your computer and use it in GitHub Desktop.
Blank jQuery plugin with helper object
(function($) {
function FooBar($scope) {
this.$scope = $scope;
this.init();
};
FooBar.prototype.doNothing = function() { };
FooBar.prototype.init = function() {
var that = this;
this.$scope.click(function() { that.doNothing(); });
};
$.fn.fooBar = function() {
if(!this.data('fooBar')) this.data('fooBar', new FooBar());
return this.data('fooBar');
}
$(function() { self.setTimeout(
function() { $(this).fooBar() }, 100); });
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment