How to fix jQuery Datepicker issue not triggering


​Today I was re-designing the single product layout of a spearfishing website and the purpose of the day was creating an add to cart modal popup with elementor. The aim was to save some space and place a pleasant "book this tour" button which, after clicking it, it should display a nice popup with the classic woocommerce add to cart form.

Long story short story, the website offers tours which require to specify a date during the reservation/add to cart process and I did choose to implement jQuery Datepicker running jQuery 1.12.4 (wordpress core version).

Everything was going fine until, after creating the popup and linking it to the button, I knowledge that the datepicker dialog was not showing and there were no errors. I literally went crazy guessing which could be the issue causing my headache! Both scripts and dependencies were loaded and JavaScript declaration to initialize the datepicker was working fine. So what could be the error?

After many tests, I have noticed that everything was loading properly so it must be due to a trigger problem. Googling around the right answer arrived from stack overflow. It appears JQuery datepicker has a bug and the classes "hasDatepicker" - added by jQuery DatePicker script itself - was the responsible. Click here to see the answer.

the following code fixes the jQuery not triggering issue by simply removing "hasDatepicker" class:

jQuery(function($){
    
    $('#myinput').datepicker().removeClass('hasDatepicker');
}); 

​Please, is this answer was useful for you too visit stack overflow thread linked above and rate the aswer.

0
Come fare il backup di un sito su altervista senza...
 

Comentarios

No hay comentarios por el momento. Se el primero en enviar un comentario.

Deja tu comentario

¿Ya està registrado? Ingresa Aquí
Invitado
Sábado, 25 Enero 2020

Categories

Most Popular

MC Web Solutions

marco.cariolato@yahoo.com

(0052) 984 142 1381

Playa del Carmen, Mexico

© 2016 - 2020 Mc Web Solutions. All Rights Reserved.