What is the best way to create a calendar with JavaScript like the jquery Datepicker where I can add some more functionality?
I want to display some arrays of dates in different colors in it as well as selecting a date.
Shall I try to edit the source code, or better, use some library and do it myself?
For the first case I would like to find some good documentation of the jquery Datepicker source. For the second I would like to find some library, which creates a good and easy to use calendar.
What is the best way to create a calendar with JavaScript like the jquery Datepicker where I can add some more functionality?
I want to display some arrays of dates in different colors in it as well as selecting a date.
Shall I try to edit the source code, or better, use some library and do it myself?
For the first case I would like to find some good documentation of the jquery Datepicker source. For the second I would like to find some library, which creates a good and easy to use calendar.
Share Improve this question edited Oct 5, 2010 at 9:32 Reigel Gallarde 65.3k21 gold badges125 silver badges142 bronze badges asked Oct 5, 2010 at 8:57 hellehelle 11.7k9 gold badges57 silver badges85 bronze badges4 Answers
Reset to default 5I want to display some arrays of dates in different colors in it as well as selecting a date.
jQueryUI's datepicker already have this.
crazy demo
$(function() {
var someDates = ['10/8/2010', '10/28/2010', '10/30/2010']; // the array of dates
$("#datepicker").datepicker({
beforeShowDay: function(date) {
for (var i = 0; i < someDates.length; i++) {
if (new Date(someDates[i]).toString() == date.toString()) {
return [true,'someDates']; // someDates here is a class
// with that added class you could do your style..
// html would then be rendered something like this,
// <td class="someDates"><a href="">8</a></td>
}
}
return [true];
}
});
});
and you could do more. Try reading event-beforeShowDay
If you don't mind writing some code of your own, you could try my calendar-logic.js.
It does no UI at all. You'll get full control of the look and behaviour of the calendar, without having to worry about the math behind how many weeks there are in a month, etc.
The jQuery Datepicker widget already provides enough functionality for a calendar. Adding custom colors is more of a style (thus CSS) thing. Also, documentation is very easy to find, so is Googling for it.
Lastly, editing the source code is never a good idea, since an upgrade will overwrite your changes.
Have a look at the extjs calendar - it looks far more extensible - and there is a pro version (paid for ) as well
http://www.sencha./blog/2010/09/08/ext-js-3-3-calendar-ponent/