Created
October 14, 2010 23:07
-
-
Save jmitchener/627255 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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