• Hi,

    first of all…sorry for my english :/.
    I want to use the Datepicker in a Template for my Custom Post Type. There are 3 Textfields to filter the Query and the Datepicker should be one of them. If i click in the Textfield the Datepicker pop up but i can’t select a Date!! I searched yesterday for hours but i cant find a solution. I use a Child-Them from Catch-Box and this function is in my functions.php

    function meine_scripts() {
        wp_enqueue_script('meinscript', dirname(get_bloginfo('stylesheet_url')) . '/js/meinscript.js', array('jquery') );
        wp_enqueue_script('jquery');
        wp_enqueue_script('jquery-ui-core');
        wp_enqueue_script('jquery-ui-datepicker');
        wp_enqueue_style('jquery.ui.theme', dirname(get_bloginfo('stylesheet_url')) . '/js/jquery-ui-1.10.4.custom.css');
    }
    add_action( 'init', 'meine_scripts' );

    And so looks the file meinscript.js

    jQuery(document).ready(function() {
        jQuery('.meindatum').datepicker({
            monthNames: ['Januar','Februar','Maerz','April','Mai','Juni',
                         'Juli','August','September','Oktober','November','Dezember'],
                         monthNamesShort: ['Jan','Feb','M?r','Apr','Mai','Jun',
                         'Jul','Aug','Sep','Okt','Nov','Dez'],
                         dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
                         dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
                         dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
            //dateFormat : "dd.mm.yyyy",
            firstDay : 1
        });
    });

    I hope you can help me.

    Thank’s
    Ati74

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Ati74

    (@ati74)

    Can anybody help me, or is this maybe the wrong section? Should i place my promlrm in “How-To an Troubleshooting” or an another section?

    Ati74

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Does your console show any errors?

    What happens if you use get_stylesheet_directory_uri() rather than dirname(get_bloginfo('stylesheet_url')) ??

    Thread Starter Ati74

    (@ati74)

    get_stylesheet_directory_uri()is the same behavior. But what do you mean with console? A special plugin or where can i find the console?

    Edit: Google is your friend..sorry for this question. The console says
    TypeError: a is undefined in jquery.ui.datepicker.min.js

    Thread Starter Ati74

    (@ati74)

    Hm if i changed jQuery(‘.meindatum’).datepicker to jQuery(‘#meindatum’).datepicker and give the inputfield this Id everything works fine..if i changed back to class i can′t select a date.

    if (nodeName == 'input') {
        this._connectDatepicker(target, inst);
    } else if (inline) {
        this._inlineDatepicker(target, inst);
    }

    put this code to your jQuery.datepicker

    Thread Starter Ati74

    (@ati74)

    Hm i hope i changed the code correctly…but now the datepicker doesn′t pop up. My code looks actaully like this

    jQuery(document).ready(function() {
        jQuery('.datpicker').datepicker({
    		if (nodeName == 'input') {
    this._connectDatepicker(target, inst);
    } else if (inline) {
    this._inlineDatepicker(target, inst);
    }
    	   	monthNames: ['Januar','Februar','Maerz','April','Mai','Juni',
        	             'Juli','August','September','Oktober','November','Dezember'],
        	             monthNamesShort: ['Jan','Feb','M?r','Apr','Mai','Jun',
        	             'Jul','Aug','Sep','Okt','Nov','Dez'],
        	             dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
        	             dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
        	             dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
            dateFormat : "dd.mm.yy",
            firstDay : 1
        });
    });

    If i use the ID-Selector everythings works fine

    use button icon and write this code.
    Hope this may be work

    $('.fromDatePicker').datepicker({
        // existing options
        showOn: "both",
        buttonImage: "images/calendar_icon_a1.jpg",
        buttonImageOnly: true
    });
    $(function(){
        $('.datepickerclass').on('click', function() {
            $(this).datepicker({showOn:'focus'}).focus();
        });
    });

    [Please use backticks for code]

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hm if i changed jQuery(‘.meindatum’).datepicker to jQuery(‘#meindatum’).datepicker and give the inputfield this Id everything works fine..if i changed back to class i can′t select a date.

    I’m not entirely sure what your markup looks like but that could be a possible issue. Have you looked at examples at https://jqueryui.com/datepicker/ to see if you may be doing things right/wrong?

    Thread Starter Ati74

    (@ati74)

    Hi,

    here is my update.

    @digitalbhavin
    Your code changed nothing…sorry

    @jose Castaneda
    The example use the ID-selector, and this works for me.

    I think we should stop at this point and i use the ID-Selektor, because this works and everything is fine.

    Thank you very much for your advises.

    Ati74

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘jQuery Datepicker can't select a date’ is closed to new replies.