Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
a jQuery plugin base to create new jQuery plugins
// app.js
param2: 'custom param2'
$.fn.calendarize = function(opt){
/* if there are no elements then just return */
if (!this.length) return this;
var defaults = {
param1: 'param1',
param2: 'param2'
var options = $.extend(defaults,opt);
alert('param1 has value ' + options.param1);
alert('param2 has value ' + options.param2);
return this.each(function(){
// real business logic will go in here
// options is directly accessible. No need to pass it around
var $this = $(this);
function test1(){
alert('this is test1');
function test2(){
alert('this is test2');
}); // end of return this.each(function())
}; // end of plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.