Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.19k stars 898 forks source link

[BUG] datepicker field gives js error $(...).datepicker not defined #449

Closed dobromir-hristov closed 7 years ago

dobromir-hristov commented 7 years ago

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.

adbmdp commented 7 years ago

Same bug for me.

gilbertsmink-zz commented 7 years ago

was just about to post this

KevinRignault commented 7 years ago

I also have this bug !

OwenMelbz commented 7 years ago

Curious to know if it was caused maybe by this PR? https://github.com/Laravel-Backpack/CRUD/pull/408/commits/987f2d5644c851486387b2a21e8613271301cfa8

If you guys could reverse the change made in that commit, and see if it fixes it, then we know the culprit

KevinRignault commented 7 years ago

Hi @OwenMelbz, Thanks for your answer. I made those changes and also tested your last fix. The datepicker works fine but if I have an address field (with the autocomplete), this field doesn't works anymore.

mariavilaro commented 7 years ago

Same problem here, and yes if I revert #408 it works

jhivan commented 7 years ago

I have a similar issue. 'date' type works fine but when i use 'date_picker' (even when copy pasted from docs) chrome and firefox throws this error:

TypeError: $(...).datepicker is not a function[Learn More]

MarcosBL commented 7 years ago

Have you tried this ? https://github.com/Laravel-Backpack/CRUD/pull/159#issuecomment-282491621

Athuli7 commented 7 years ago

I had mentioned this error as PR in the Base Repo. https://github.com/Laravel-Backpack/Base/pull/110 jQuery ui is not loaded.

ghost commented 7 years ago

Adding the jquery ui fixed it for me.

Athuli7 commented 7 years ago

@skatika, yes. But it needs to be a part of the Base. And I've made the PR. But no response.

pavoltanuska commented 7 years ago

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.

tabacitu commented 7 years ago

@pavoltanuska , I love your reply, and I completely agree with your temporary fix. Would merge it right away if you can submit a PR.

I can't say I have "a strategy" for outdated packages in dependencies, but:

Cheers!

pavoltanuska commented 7 years ago

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.

tabacitu commented 7 years ago

That would be great, thank you!

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

kanyapila-101 commented 7 years ago

I can not used datetimepicker on mac os Is I used Modal BS. datetimepicker display background modal Help Me.

lloy0076 commented 7 years ago

@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.