I was trying to highlight certain dates in a calendar using jQuery datepicker. I found the following code on this forum from Mark Murphy, Highlight dates in specific range with jQuery's datepicker which works perfectly, butt there are a couple of bits in the code that I don't understand. I can't post a comment on the original answer as I don't have enough privileges.
What I would like to know is:
1) what is the purpose of the || '' in the bit which returns the matching date (function returns true)?
2) what is the purpose of the , when the function returns false?
$(document).ready(function() {
var dates = {'2012/6/4':'some description' , '2012/6/6':'some other description'};
$('#datepicker').datepicker({
beforeShowDay: function(date) {
var search = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + (date.getDate());
//console.log(search);
if (dates[search]) {
return [true, 'highlight', dates[search] || ''];
}
return [false, '', ''];
}
});