Home » Jquery » javascript – jquery-ui datepicker this.element.uniqueId is not a function

javascript – jquery-ui datepicker this.element.uniqueId is not a function

Posted by: admin February 22, 2020 Leave a comment

Questions:

I am trying to use jquery-ui/ui/widgets/datepicker, but I get the error “this.element.uniqueId is not a function” caused from jquery-ui/ui/widgets/dialog.js:401:

""aria-describedby": this.element.uniqueId().attr( "id" )".

I am using jquery > 1.9, so the uniqueId() function should be there according to the documentation.
I have already tried different jQuery and jQueryUI versions, but the error still remains.

I am using jquery 3.4.1 and jquery-ui 1.12.1.

What’s causing the issue here and how to fix it?

Edit:
This is my src/index.js

window.$ = window.jQuery = require("jquery");

var ui = require('jquery-ui');
$.ui = ui;

require('jquery-ui/ui/widgets/dialog');
require('jquery-ui/ui/widgets/tabs');
require('jquery-ui/ui/widgets/datepicker');

And in my layout file I have included the built app.js and try the following code

$(document).ready(function() {

    $("#date-picker").datepicker();

    $("#box-tabs, #box-left-tabs").tabs();

});

When I remove the require of the datepicker the error does not come.

How to&Answer: