amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.02k forks source link

Prevent datepicker from opening when clicking the input #1182

Open ericdevjs opened 4 years ago

ericdevjs commented 4 years ago

Hi,

My goal in to have a button that triggers the datepicker but I don't want the input to trigger the datepicker only the button but if it's not the input that triggers the datepicker the input is not updated with the new date I pick.

Any ideas ?

Thanks

tbuyle commented 4 years ago

This is doable using the .off method : https://amsul.ca/pickadate.js/api/#method-off

// Get the input
let pickInput = $("#my_date_input") 
// Init pickadate
pickInput.pickdate({...})
// Disable Opening of Date Picker on click or focus
pickInput.off("focus")
pickInput.off("click")

You'd have to add the code so that the button open the picker initalised for pickInput - and then the selected that will be updated when you pick a date. something like : pickInput.pickadate("picker").open()