Skip to content

Instantly share code, notes, and snippets.

@jmitchener
Created October 14, 2010 23:07
Show Gist options
  • Save jmitchener/627255 to your computer and use it in GitHub Desktop.
Save jmitchener/627255 to your computer and use it in GitHub Desktop.
JSTest.Calendar = (function() {
// constructor
var cal = function(element, name) {
this.name = name;
this.element = $(element);
this.element.html("I'm " + this.name);
this.refresh(); //call instance method
cal.someFunc(); //call static method
}
// instance methods
cal.prototype = {
refresh: function() {
this.element.append(' refreshed['+this.name+']');
},
};
// static methods
$.extend(cal, {
someFunc: function() {
alert('called someFunc()');
}
});
return cal;
})();
$(document).ready(function() {
$('.calendar').each(function() {
new JSTest.Calendar(this, 'cal_' + Math.floor(Math.random()*1000));
});
$('#button').click(function() {
JSTest.Calendar.someFunc();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment