jonthornton / Datepair.js

A javascript plugin for intelligently selecting date and time ranges, inspired by Google Calendar.
https://www.jonthornton.com/Datepair.js
358 stars 87 forks source link

cannot make datepicker visible when clicking on glificon #140

Closed jtestacc1 closed 1 year ago

jtestacc1 commented 1 year ago

Hello, this is a small issue but it is driving me crazy, maybe you can help. I have a form where I have a calendar icon displayed right next to the date input field. I want to show the Date picker when I click on the icon as well. I did it with other datepickers, but seems that if I am using Datepair, it doesn't work (datepicker.show() is not doing anything). Lint to test: https://rmv.ro/temp/test1.php

My code is:

 $('.date-input .time').timepicker({
        'showDuration': true, 
        'timeFormat': 'H:i', 
        'disableTouchKeyboard' : true 
    });
    $('#start_date').datepicker({ 'format': 'dd/mm/yyyy', 'autoclose': true });
    $('#end_date').datepicker({ 'format': 'dd/mm/yyyy', 'autoclose': true });
    $(".start-date-addon").click(function(){ console.log("icon1 was clicked"); $("#start-date").datepicker('show') });
    $(".end-date-addon").click(function(){ console.log("icon2 was clicked"); $("#end-date").datepicker('show') });
    $('.date-input').datepair();

There must be a way to show the Datepicker on demand when clicking on other elements, I presume? Thank you

jonthornton commented 1 year ago

I'm unable to help with questions about the Datepicker plugin, my apologies.