• mathishuettl

    (@mathishuettl)


    This question may already have an answer here:

    jquery-ui and webpack, how to manage it into module? 5 answers
    No, my question is different. I will edit to explain how.
    I try to use jquery-ui datepicker in my WordPress theme, but I failed with it. I use npm as package manager, so I tryed to install it with npm, but this didn’t work, so I installed it manually and downloaded jquery-ui from the website and require it into my main.js file.

    var $ = jQuery;
    var axios = require("axios");
    var datetimepicker = require("./jquery-ui.js");
    
    $(document).ready(function() {
        $("#dp").datepicker();
    });

    Error: Uncaught TypeError: $(…).datepicker is not a function

Viewing 1 replies (of 1 total)
  • wpaart

    (@wpaart)

    The error ‘uncaught TypeError:$(…).datepicker is not a function’ tells us that the datepicker function is not available when you’re custom javascript tries to call it.

    jQuery is loaded as part of the default WordPress Installation. There is actually no need to install jQuery yourself.

    To use the jQuery functionality you should load the scripts from within your plugin or theme code. This way the datepicker functionality will already be loaded and available when you’re custom javascript is calling the datepicker function.

    The WordPress developer handbook explains in detail how to include javascript.
    developers handbook

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress include jQuery-ui Datepicker’ is closed to new replies.