Figured out that I needed to have the right js dependencies declared. This code now works. Hope it helps someone else with the same problem.
Key line array('jquery-ui-core' ,'jquery-ui-datepicker', 'jquery-ui-slider')
Full `wp-enqueue’ code:
function pbd_events_jquery_datepicker() {
wp_enqueue_script(
'jquery-ui-datepicker',
get_bloginfo('template_directory') . '/jquery-ui-datepicker/jquery-ui-1.8.16.custom.min.js',
array('jquery')
);
wp_enqueue_script(
'jquery-ui-timepicker-addon',
get_bloginfo('template_directory') . '/jquery-ui-datepicker/jquery-ui-timepicker-addon.js',
array('jquery-ui-core' ,'jquery-ui-datepicker', 'jquery-ui-slider')
);
wp_enqueue_script(
'pbd-datepicker',
get_bloginfo('template_directory') . '/jquery-ui-datepicker/pbd-datepicker.js',
array('jquery', 'jquery-ui-datepicker' , 'jquery-ui-timepicker-addon')
);
}
add_action('admin_print_scripts-post-new.php', 'pbd_events_jquery_datepicker');
add_action('admin_print_scripts-post.php', 'pbd_events_jquery_datepicker');
/**
* Adds CSS for the jQuery datepicker script to Event pages.
* http://jqueryui.com/demos/datepicker/
*/
function pbd_events_jquery_datepicker_css() {
wp_enqueue_style(
'jquery-ui-datepicker',
get_bloginfo('template_directory') . '/jquery-ui-datepicker/css/smoothness/jquery-ui-1.8.16.custom.css'
);
wp_enqueue_style(
'jquery-ui-timepicker-addon',
get_bloginfo('template_directory') . '/jquery-ui-datepicker/css/jquery-ui-timepicker-addon.css'
);
}
add_action('admin_print_styles-post-new.php', 'pbd_events_jquery_datepicker_css');
add_action('admin_print_styles-post.php', 'pbd_events_jquery_datepicker_css');