The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

jQuery date picker in admin? (8 posts)

  1. f00bar
    Posted 6 years ago #

    Hey everyone - sorry for post-whoring today...

    I've searched on the support forum for this but cannot find an answer. I'm trying to implement the datepicker() from jQuery in order to create a simple date entry field in my plugin for adding club events to a database. I've referenced the jQuery site and put in the code that supposedly is meant to trigger the datepicker but nothing happens. Is there something I'm missing, or are there restrictions in wordpress for datepickers or something?

  2. swedish boy
    Posted 6 years ago #

    I succeded doing this by copying the needed files to my theme directory.
    The files needed are (minimized versions work too):
    jquery-xxx.js (xxx=version number)
    a theme folder for styling

    You can also add a localization file to get weekdays and names for your country/language. in my case sweden i add the ui.datepicker-sv.js file.

    Then add the following code to where you want to use your datepicker (i added it to a function that echoed a meta-box for posts)
    I put all the mentioned files inside a js directory inside my theme.

    <!-- css -->
    <link type="text/css" href="<?php bloginfo("template_url"); ?>/js/YOUR_SELECTED_THEME/ui.all.css" rel="stylesheet" />
    <!-- replace YOUR_SELECTED_THEME with the theme folder you picked -->
    <!-- jquery scripts -->
    <script type="text/javascript" src="<?php bloginfo("template_url"); ?>/js/jquery-1.3.2.js"></script>
    <script type="text/javascript" src="<?php bloginfo("template_url"); ?>/js/ui.core.js"></script>
    <script type="text/javascript" src="<?php bloginfo("template_url"); ?>/js/ui.datepicker.js"></script>
    <!-- optional localization file -->
    <script type="text/javascript" src="<?php bloginfo("template_url"); ?>/js/ui.datepicker-sv.js"></script>	
    <script type="text/javascript">
    	var $j = jQuery.noConflict();
    	$j(function() {
    <p><input type="text" id="datepicker" name="date"></p>
  3. Yahzee Skellington
    Posted 6 years ago #

    I did the same thing but then it conflicted with other jquery-ui functions that were loaded by WordPRess

  4. Alisa R. Herr
    Posted 5 years ago #

    I am also getting an error when I implement datepicker in the admin area:

    this._mouseInit is not a function
    in file: load-scripts.php (line 67)

    This breaks all of the other js functions loaded by WP. Anyone know of a way around this or a way to fix this?

    Any help would be appreciated!

  5. Alisa R. Herr
    Posted 5 years ago #

    Found help on this thread:

    I downgraded to 1.7.3 and now it's not throwing any errors.

    Hope this helps someone else.

  6. bjorsq
    Posted 5 years ago #

    This worked for me - downloaded the 1.7.3 version of datepicker, then stripped out ui-core from the download js script (I downloaded a package to get the theme) and added my line to initialise the datepicker to it. Added to wp-admin like this:

    wp_enqueue_script('datepickerScript', get_bloginfo('template_url') . '/js/jquery-ui-datepicker.min.js', array('jquery','jquery-ui-core'));

    Also added smoothness theme like this:

    wp_enqueue_style('datepickerStyle', get_bloginfo('template_url') . '/css/smoothness/jquery-ui-smoothness.css');

    This assumes you have the relevant CSS and JS in your theme.

  7. maxemil
    Posted 5 years ago #

    downgrading to legacy jquery ui 1.7.3 is the answer when including datepicker to an admin page like posts.php - even for wordpress 3.01.

    Hopefully the WP team will update the jquery UI core (just load the full UI package guys) in a very soon release - this is somewhat annoying :)

  8. maxemil
    Posted 5 years ago #

    well.. looking at the core 3.1 track discussion, it seems jQuery UI will be updated.


Topic Closed

This topic has been closed to new replies.

About this Topic