Support

Account

Home Forums Backend Issues (wp-admin) Datepicker is not a function

Solving

Datepicker is not a function

  • I’m using Advanced Custom Fields Pro Version 5.3.5 and WordPress 4.4.2. I’m getting this error in the console:

    Uncaught TypeError: this.$input.addClass(…).datepicker is not a function

    acf.fields.date_picker.acf.field.extend.initialize @ acf-input.min.js?ver=5.3.5:1(anonymous function) @ acf-input.min.js?ver=5.3.5:1c @ acf-input.min.js?ver=5.3.5:1t @ acf-input.min.js?ver=5.3.5:1acf.do_action @ acf-input.min.js?ver=5.3.5:1acf.fields.acf.model.extend._ready_field @ acf-input.min.js?ver=5.3.5:1c @ acf-input.min.js?ver=5.3.5:1t @ acf-input.min.js?ver=5.3.5:1acf.do_action @ acf-input.min.js?ver=5.3.5:1(anonymous function) @ acf-input.min.js?ver=5.3.5:1m.extend.each @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery…:2m.fn.m.each @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery…:2acf.fields.acf.model.extend._ready @ acf-input.min.js?ver=5.3.5:1c @ acf-input.min.js?ver=5.3.5:1t @ acf-input.min.js?ver=5.3.5:1acf.do_action @ acf-input.min.js?ver=5.3.5:1(anonymous function) @ acf-input.min.js?ver=5.3.5:1j @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery…:2k.fireWith @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery…:2m.extend.ready @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery…:2J @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery…:2

  • At a guess, I say this is because you’re using a plugin that compacts all the JS and the JS for ACF is not being localized properly.

  • I got same error.

    The reason is that Javascript is loaded before acf_form() generating ACF elements.

    Bad case.

    <?php
    acf_form_head(); // <-- bad!
    get_header();
    ?>
    
    <?php acf_form(...); ?>

    Correct.

    <?php
    get_header();
    acf_form_head();  // <--- here!
    ?>
    
    <?php acf_form(...); ?>
  • This makes sense, but the code the order give by @yousan will cause other problem, like a “headers already sent” error.

    If you must do this then I would suggest adding an output buffer to prevent the error, and to be honest I’m not sure this won’t cause other problems.

    
    <?php 
      ob_start();
      get_header();
      acf_form_head();  // <--- here!
      echo ob_get_clean();
    ?>
    
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Datepicker is not a function’ is closed to new replies.