<script type="text/javascript">
$(function(){
function getJsonDate(year, month) {
themonth = year.toString() + month.toString();
switch (themonth)
{
case "20108": // the year 2010 and month 8 august
thefile = "august2010.txt"; //file with the links
break;
case "20107":
thefile = "july2010.txt";
break;
default:
thefile = "blank.txt";
}
$.getJSON(thefile, function(data) {
var i = 0;
for (i = 0; i < data.data.length; i++)
{
$('.ui-datepicker-calendar td a:exactly('+data.data*['d']+')')
.css({color: '#f00'})
.attr('href',data.data*['link'])
.parent().attr('onclick','');
}
});
}
$.expr[":"].exactly = function(el, i, m) {
var s = m[3];
if (!s) return false;
return eval("/^" + s + "$/i").test($(el).text());
};
$('#datepicker').datepicker({
inline: true,
onSelect: function(dateText, inst) {
Date.prototype.toString = function () {return isNaN (this) ? 'NaN' : [this.getDate(), this.getMonth(), this.getFullYear()].join('/')}
d = new Date(dateText);
getJsonDate(d.getFullYear(), d.getMonth()+1);
},
onChangeMonthYear: function(year, month, inst) {
//alert(year);
//alert(month);
getJsonDate(year, month);
}
});
});
</script>
im using the jquery ui datepicker andhave this code that adds links to the dates.
however on first load the getJsonDate isnt firing. It only runs when the user switches months.