Hi guys I have added jQuery and my jQuery fail to my main plugin page and it works great by this was.
function load_scipt() {
wp_register_script( 'reserveit', plugins_url( '/js/reserveit.js', __FILE__ ), array( 'jquery' ), '2.5.1' );
wp_enqueue_script( 'reserveit' );
wp_register_script( 'datetimepicker', plugins_url( '/lib/datetimepicker/js/jquery-ui-timepicker-addon.js', __FILE__ ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-slider', 'jquery-ui-datepicker' ) );
wp_enqueue_script( 'datetimepicker' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'jquery-ui-slider' );
wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
}
add_action( 'wp_enqueue_scripts', 'load_scipt' );
Now I need to add jQuery datepicker to input in my admin menu, but it isn't working here is the code.
function load_scipts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-widget' );
wp_register_script( 'admin-menu', plugins_url( 'admin-menu.js', __FILE__ ), array( 'jquery', 'jquery-ui-datepicker' ), '2.5.1' );
wp_enqueue_script( 'admin-menu' );
wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
}
add_action( 'wp_enqueue_scripts', 'load_scipts' );
I tried everything but it isn't working. my path to files working but I have no idea where can the problem is.
this is my reserveit.js
jQuery(document).ready(function($) {
jQuery('#datepicker').datepicker({
dateFormat: 'dd-mm-yy'
});
});
and this is my admin-menu.js
jQuery(document).ready(function(jQuery) {
jQuery('#datepicker').datepicker({
dateFormat: 'dd-mm-yy'
});
});
Please if you have idea write comment.