Introduction
So I have written several jQuery plugins and over the years, I have developed a basic foundation for starting a new plugin.
Background
This is a piece of JavaScript code that I have gathered and developed over the years. When I first started to write plugins, a lot of it just confused me. Hopefully, if you are new and/or interested in jQuery and wanting to write your own plugins, this will help.
Using the Code
I have tried to comment the code as reminders for myself when developing a new plugin but also a guide for any other developers starting from scratch.
So I am going to let the following code just speak for itself:
(function($) {
$.fn.extend({pluginName:function(options){
var plugin = this;
var defaultOptions = {
};
if (options)
plugin.Settings = $.extend(defaultOptions, options);
else
plugin.Settings = defaultOptions;
function functionName(values){
}
plugin.functionName = function(values){
}
var variableName;
plugin.variableName = function(v){
if(undefined !== v){
variableName = v;
}
return variableName;
}
return this.each(function(){
});
}});
})(jQuery);
Happy coding!!!
History
- 19-Jun-2014 - Initial release
I am software developer with over 20 years of professional experience. I have been employed as a software developer since the early 90′s back when Microsoft’s Windows 3.1x was gaining popularity and IBM’s OS/2 was the predominant leader in 32-bit PC based Operating Systems.
Prior to choosing this as my profession I had studied architecture and then later Electrical and Mechanical engineering in college. As a young kid growing up I always played with computers, my first computer was a TRS-80 that I would spend countless hours writing programs for, I never really thought of programming as a profession. The story goes that in my final year of college I took a C/C++ programming class and had so much fun working on the various projects that my professor told me something that changed everything.
“You know they pay people to do stuff like this for a living?” – Professor Bolman
Check out my blog
here.
My current and ever evolving projects:
jqAlert javascript alerts done right for those using jQueryUI.
DooScrib Doodle and scribble pad written in javascript for use with HTML5 Canvas.