Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-Only datepicker. #113

Open
InKairo opened this issue May 21, 2022 · 3 comments
Open

Read-Only datepicker. #113

InKairo opened this issue May 21, 2022 · 3 comments

Comments

@InKairo
Copy link

InKairo commented May 21, 2022

Can we add an option to config the datepicker so that if it's true, it shows the datepicker with the selected date or do not show the datepicker at all?

The main reason I want this is because I have an input that holds the datepicker, but there are several occasions where I want the date not to be changed, only shown.

So I though that maybe reading the value of the readonly input and hiding the datepicker in a show event could work, but I see this as a hacky way of preventing something to show in the first place.

So having an option to make the whole datepicker "readonly" would benefit not only performance, but avoid potential flickers on screen (due to fast show and hide) and also make inline datepickers able to show a date but not allow to change it.

I'm very sorry if this already exist on some way, but I read the whole documentation several times and didn't find something that could fit this need. Thanks in advance! I think this is the best picker all around!

@InKairo
Copy link
Author

InKairo commented May 21, 2022

so, to show visually what I think would be awesome and simple, is to:
if option
read-only : true
then
hide prev and next buttons
change background
disable onclick events over the datepicker

The background could be handled with an array on the read-only option like:
read-only: [true, "#dbdbdb"]

image

@mymth
Copy link
Owner

mymth commented May 22, 2022

Is this like what you are trying to make?
https://codepen.io/mymth/pen/qBxXEKV

By the way, adding an option not to show datepicker when input has readonly attribute is planned.
(see the second last paragraph of #98 (comment))

I think the specs in your second post doesn't necessarily meet most people's preferences and some other people probably prefer a bit different way to make the picker read-only. So I'm reluctant to add such an option and would like users to make their own version of read-only datepicker themselves because, as you can see in the above demo, it can be done without touching the library's source code.

@InKairo
Copy link
Author

InKairo commented Jun 9, 2022

Yes! that is exactly what I need! I'll check it out because I still develop in plain js/jquery

Well. It's true that you can do everything without touching the library's source code. I think that the readonly attribute is just enough for most of people needs. Thanks!

mymth added a commit that referenced this issue Feb 12, 2023
bugfix: date picker enters edit mode when the input is readonly
#98, #113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants