Created
April 28, 2014 15:24
-
-
Save dniswhite/11375377 to your computer and use it in GitHub Desktop.
starting point for a jQuery plugin
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($) { | |
// using $.fn.extend allows us to expand on jquery | |
$.fn.extend({pluginName:function(options){ | |
// save a link to your instance | |
var plugin = this; | |
var defaultOptions = { | |
// add what you know are default values for your options | |
}; | |
// connect your default values to what the user has added | |
// I connect everything into the current instance so that it | |
// can be referenced later if needed. | |
if (options) | |
plugin.Settings = $.extend(defaultOptions, options); | |
else | |
plugin.Settings = defaultOptions; | |
// private functions | |
function functionName(values){ | |
// code here | |
} | |
// public functions | |
plugin.functionName = function(values){ | |
// code here | |
} | |
// implement get/set for your object properties | |
var variableName; | |
plugin.variableName = function(v){ | |
// validate data sent in | |
if(undefined !== v){ | |
variableName = v; | |
} | |
return variableName; | |
} | |
return this.each(function(){ | |
// initialization code goes here | |
}); | |
}}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment