JQuery Datepicker not showing on clean WP install
-
Hello
I got a strange error trying to get the jquery datepicker to work using the WordPress built-in jquery libraries.
Initially I was trying this on a mature site (running the lastest WP) which has a certain number of plugins and could not get it to work. Reading around on various forums about the countless ways the datepicker can fail due to jquery conflicts, I decided to get it to work on a fresh install of WP 4.3 with no plugins and twentyfifteeen theme running. No luck!
Here is the code I am running, I am loading the jquery libraries from WP in the
functions.php
file,add_action( 'wp_enqueue_scripts' , 'my_scripts' , 999 ); function my_scripts() { wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_style('jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); }
Then I set up my input field and fire the datepicker function on document load,
<p> Date <input type="text" class="hasDatepicker"> </p> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('.hasDatepicker').datepicker({ dateFormat : 'yyyy-mm-dd' }); }); </script>
When the page loads, no error on the js console, but a datepicker div element is correctly inserted into the page.
<div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>
However this is empty. If I run the same code with a static html page, the above
<div>
get populated with various other elements which show up the calendar as expected.Anyone come across this issue and found a solution?
- The topic ‘JQuery Datepicker not showing on clean WP install’ is closed to new replies.