I have the current code for enqueuing the jQuery Date Picker:
function register_my_scripts()
{
wp_register_script('scripts', plugins_url('/js/scripts.js', __FILE__));
wp_enqueue_script('scripts');
wp_enqueue_script('jquery-ui-datepicker');
}
function register_my_styles()
{
wp_enqueue_style('e2b-admin-ui-css','http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css',false,"1.9.0",false);
}
add_action('wp_enqueue_scripts', 'register_my_scripts');
add_action('wp_enqueue_scripts', 'register_my_styles');
the jQuery function which is inside scripts.js:
jQuery(document).ready(function(){
jQuery('.datepicker').datepicker({
dateFormat : 'D, m/d/yy'
});
});
and the html field:
<input type="text" class="datepicker"/>
This code work fine on the front end but for some reason doesn't do anything on the back end. I only need it to work on the backend.
What's going on here?
Probably, you need to serve your scripts on admin_enqueue_scripts
instead of wp_enqueue_scripts
add_action('admin_enqueue_scripts','register_my_scripts');
See this link for more details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With