Skip to content

Instantly share code, notes, and snippets.

@ckpicker
Last active December 25, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ckpicker/7030311 to your computer and use it in GitHub Desktop.
Save ckpicker/7030311 to your computer and use it in GitHub Desktop.
Community Events Add-on // Add Javascript to change datepicker format
add_action( 'wp_footer', 'community_add_javascript', 100 );
function community_add_javascript() {
if (tribe_is_community_edit_event_page()) {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Customize Events Community Datepicker
if(jQuery(".your-customer-datepicker-class").length) {
var datepickerOpts = {
dateFormat: 'mm-dd-yy',
changeMonth: true,
changeYear: true,
onSelect: function(selectedDate) {
var option = this.id == "EventStartDate" ? "minDate" : "maxDate";
var instance = jQuery(this).data("datepicker");
var date = jQuery.datepicker.parseDate(instance.settings.dateFormat || jQuery.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).not('#recurrence_end').datepicker("option", option, date);
}
}
var dates = jQuery(".your-customer-datepicker-class").datepicker(datepickerOpts);
}
});
</script>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment