Created
February 17, 2011 21:11
-
-
Save thinkt4nk/832701 to your computer and use it in GitHub Desktop.
calendar with events on date jui
This file contains 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
<script type="text/javascript"> | |
function highlightDates(date) { | |
for ( var i = 0; i < agenda.length; i++) { | |
var start = agenda[i].substring(0,4) + '-' + num_pad(parseInt(agenda[i].substring(5,7)-1),2,'0') + '-' + agenda[i].substr(8,2); | |
//var start = agenda[i].date; | |
var dateString = date.getFullYear() + '-' + num_pad(date.getMonth(),2,'0') + '-' + num_pad(date.getDate(),2,'0'); | |
if (start == dateString) { | |
return [ true, 'ui-state-active' ]; | |
} | |
} | |
return [ false, '' ]; | |
} | |
var agenda = []; | |
$(document).ready(function() { | |
$('div.jui-datepicker-bind').each(function() { | |
var $this = $(this); | |
$(this).datepicker({ | |
changeMonth : true, | |
changeYear : true, | |
beforeShowDay : highlightDates, | |
onSelect : function() { | |
var selectDate = $.datepicker.formatDate('yy-mm-dd',$(this).datepicker('getDate')); | |
$.get('<?php echo SiteHelper::alterCurrentLink(array('action'=>'ajaxGetCustomerPurchases')); ?>&date=' + selectDate,function(data) { | |
$('.purchaseInformation').html(data); | |
}); | |
}, | |
onChangeMonthYear : function(year,month,inst) { | |
$.get('<?php echo SiteHelper::alterCurrentLink(array('action'=>'ajaxGetDatesByMonthYear')); ?>&year=' + year + '&month=' + month,function(data) { | |
agenda = data; | |
$this.datepicker('refresh'); | |
},'json'); | |
} | |
}); | |
var date = $this.datepicker('getDate'); | |
var year = date.getFullYear(); | |
var month = date.getMonth(); | |
$.get('<?php echo SiteHelper::alterCurrentLink(array('action'=>'ajaxGetDatesByMonthYear')); ?>&year=' + year + '&month=' + month,function(data) { | |
agenda = data; | |
$this.datepicker('refresh'); | |
},'json'); | |
$(this).datepicker('show'); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment