Home > Net >  Datepicker not working for ONE user: Query.Deferred exception: $(...).datepicker is not a function T
Datepicker not working for ONE user: Query.Deferred exception: $(...).datepicker is not a function T

Time:03-19

I have an odd issue where the date picker works for me in Chrome and it works for other users. However, it doesn’t pop up at all for one user on his Chrome (so far, just one user has this issue) and I’m not sure why?

Anyone have ideas? We’ve tested in incognito mode on his machine and he still got the issue. Error message like this is on his chrome dev console:

Query.Deferred exception: $(...).datepicker is not a function TypeError: $(...).datepicker is not a function at HTMLDocument. (http://192.168.20.52:9891/static/js/validate.js:2:17) at e (https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js:2:30005) at t (https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js:2:30307) undefined S.Deferred.exceptionHook @ jquery.min.js:2 t @ jquery.min.js:2 setTimeout (async)

My code ( in validate.js):

$(function() {
    $("#start").datepicker({
        dateFormat: 'yy-mm-dd',
        onSelect: function(dateStr) {
            console.log('In start method')
            var date = $(this).datepicker('getDate');
            date.setMonth(date.getMonth());
            console.log(date)
            $('#end').val($.datepicker.formatDate('yy-mm-dd', date));
            setNumberOfVDays()
        }
    });
});

I include this at the bottom of my html file (I am NOT including any other .js file at the top of this file)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="/static/js/validate.js"></script>

Thanks!

CodePudding user response:

please add these styles and scripts before initializing.

  <link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  <script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>

if it helps you. make sure to click on this answer is helpful.

CodePudding user response:

i'm just posting in case anyone was curious about what the issue was. it looks like it was some security thing on the computers after all. I'm not sure what/how, but it wasn't a browser-specific security block.

The workplace was blocking one of the jquery code site links so I downloaded the .js files to our own server and referred to those in my code instead of to the site links.

Using the local files appears to have fixed the problem

  • Related