Created
January 5, 2012 05:46
-
-
Save remino/1563906 to your computer and use it in GitHub Desktop.
Blank jQuery plugin with helper object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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