CRUD: [BUG] datepicker field gives js error $(...).datepicker not defined

As the title says it, I get this $(...).datepicker not defined error, but I have published all the configs and should have the vendors and everything. The datepicker.js script is loaded as well. Laravel 5.4, with latest versions of Base/Cruds etc.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@kanyapila-101 - at the very minimum we’d need to know if your debug console showed any errors (especially missing files, actual error logs and so forth) and a basic idea of your setup.

As it’s not obviously related to this issue, it might be best to open another issue and start there.

If it relates to this issue we can always reference it back to here later.

That would be great, thank you!

Just merged your PR, so let’s close this bad boy. Cheers!

Alright, thanks for the insights and of course for all the work done @tabacitu !

I’ll keep an eye on the AdminLTE’s take on this issue and will let you guys know once it’s fixed.

Well, this goes a little deeper.

First of all, the absence of jQuery UI is not the real issue here.

This all comes down to a bug in Bootstrap Datepicker which has been fixed since Oct 14, 2014.

As Backpack depends on AdminLTE (and its plugins) and AdminLTE uses outdated version of the Bootstrap Datepicker (issue already opened - https://github.com/almasaeed2010/AdminLTE/issues/1462) we’re stuck with the buggy version right now.

I’m definitely against including jQuery UI as a fix for this issue, since it’s not the right solution.

The question is, how to fix it?

@OwenMelbz @tabacitu - what’s your strategy for stuff like this (outdated packages in dependencies)? Should we add our own separate version of said package (Bootstrap Datepicker in this case) and use that one, or should we wait for fix in AdminLTE and use some kind of workaround for now?

As for the workaround (or call it a hot-fix), the best I came up with is to change the #408 to:

if (jQuery.ui) {
    var datepicker = $.fn.datepicker.noConflict();
    $.fn.bootstrapDP = datepicker;
} else {
    $.fn.bootstrapDP = $.fn.datepicker;
}

It isn’t ideal, since jQuery UI is not necessarily the only package causing conflicts here, but it’s the only one that we know of right now.