Skip to content

Instantly share code, notes, and snippets.

@atypical
Created December 20, 2012 18:25
Show Gist options
  • Save atypical/4347485 to your computer and use it in GitHub Desktop.
Save atypical/4347485 to your computer and use it in GitHub Desktop.
// Plugin definition
// Plugin definition
$.fn.moduleName = function( options ) {
var args = Array.prototype.slice.call( arguments, 1 );
return this.each(function() {
var self = $(this),
moduleName = self.data('moduleName');
// If we don't have a stored moduleName, make a new one and save it
if ( !moduleName ) {
moduleName = new ModuleName( self, options );
self.data( 'moduleName', moduleName );
}
if ( typeof options === 'string' ) {
moduleName[ options ].apply( moduleName, args );
}
});
};​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment