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
Attach to multiple inputs? #2
Comments
From what I can tell so far, the easiest way would involve having to create a loop:
Is there a simpler way? |
Yep that would be the quickest way. If you don't need to reference the instance later you can just do: $('.date-picker').each(function() {
new Pikaday({ field: $(this) });
}); Or better yet do this inside the loop: $('.date-picker').each(function() {
$(this).data('pikaday', new Pikaday({ field: $(this) }));
}); then later you can access: // field is a single .data-picker jQuery reference
field.data('pikaday').nextMonth(); In future I may write a small (optional) jQuery wrapper so that you can use it like other plugins. |
For anyone who has never used |
Right. The .each() and .data() approach is great. A jQuery wrapper (bundled within pikaday.js) would go a long way towards people making the switch away from jQuery UI datepicker. |
Not a bad idea :) For now I've written a jQuery version (see /plugins in the repo) — it's basically just the normal version with a wrapper heading it. I'll consider throwing this into the |
Cool. Well it looks like you're on the right track. Looking forward to seeing how this all pans out. |
Made to have (optional) input format(s) as well as an output format.
I bashed my head with this for couple of hours and didn't get any of the examples to work... no errors in log, but no datepickers either. Ended up just copying it like this: // Datepickers
var startdate = new Pikaday({
field: $('.reservation').find('#startdate')[0],
format: 'DD/MM/YYYY',
firstDay: 1
});
var enddate = new Pikaday({
field: $('.reservation').find('#enddate')[0],
format: 'DD/MM/YYYY',
firstDay: 1
}); |
Passing $(this) (jQuery object) doesn't work for me: var picker = [];
$('.date-picker').each(function(idx) {
picker[idx] = new Pikaday({ field: $(this) });
}); It only work when I use only this. The direct element. var picker = [];
$('.date-picker').each(function(idx) {
picker[idx] = new Pikaday({ field: this });
}); |
@hugomelo try to use like this var picker = [];
$('.date-picker').each(function(idx) {
picker[idx] = new Pikaday({ field: $(this).get(0) });
}); var picker = [];
$('.date-picker').each(function(idx) {
picker[idx] = new Pikaday({ field: $(this)[0] });
}); |
Hello, i am using Ninja form, is there a way to select different dates in the Pickaday calendar in the same form field separeted with , for example? |
In some cases the
|
can we select only time using pikaday |
@chethan1095, there's an explaination in the README |
what's the no jquery equivalent? |
On Mar 7, 2017, ronilaukkarinen said this method worked for him, but I'm getting nothin. When I applied Pikaday to just one input, it worked fine. But trying to apply to more than one produces no pop-up calendars on any of the input fields. For context, it's an on-line job application form.
|
@eLIANT-TechnologyServices the working code examples above are compatible with jQuery syntax, your code examples are native JS. I don't think the non-jQuery version of Pikaday supports this. See issue #123 Either add jQuery to your project (if you have a ton of fields to initialize) or if your app has a limited number of fields you can just instantiate Pikaday for each known field. |
Thanks for your reply.
From your profile picture you don't appear to be a child, so maybe you can
appreciate what I'm about to say.
Dude, I'm tired of learning new languages. I've gone through 14 different
programming, scripting, and report-writing languages in my carrier - since
before there were PCs.
I really do appreciate your response, but I just started with JS this year,
and I don't think I could make myself study hard enough to understand the
meaning of
$('input.datep').pikaday({ firstDay: 1 });
From what I've seen, Pikaday has not been updated or supported officially
for a very long time. Is there an alternative?
Sincerely,
Philip W. Kelly
eLIANT Technology Services
<http://www.eliantservices.com/> www.eliantservices.com
937-974-5521
From: milholen <notifications@github.com>
Sent: Sunday, August 23, 2020 5:47 PM
To: Pikaday/Pikaday <Pikaday@noreply.github.com>
Cc: eLIANT-TechnologyServices <pkelly@eliantservices.com>; Mention
<mention@noreply.github.com>
Subject: Re: [Pikaday/Pikaday] Attach to multiple inputs? (#2)
@eLIANT-TechnologyServices <https://github.com/eLIANT-TechnologyServices>
the working code examples above are compatible with jQuery syntax, your code
examples are native JS. I don't think the non-jQuery version of Pikaday
supports this. See issue #123
<#123>
Easiest solution: add jQuery to your project.
-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2 (comment)> , or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQAPVFUNYM4QMUMN4JKHLCTSC
GE4DANCNFSM4ABRSU6A> .
…--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
|
lmao. Philip, since this is my company account i can't flame you. but
have a nice day. |
Look at you – making me learn something new.
Okay, first things first… how do I “activate” JQ? Like with JS I use <script>…</script>. Do I do the same thing but just put JQ between <></>?
Sincerely,
Philip W. Kelly
eLIANT Technology Services
<http://www.eliantservices.com/> www.eliantservices.com
937-974-5521
From: Tim <notifications@github.com>
Sent: Monday, August 24, 2020 3:57 AM
To: Pikaday/Pikaday <Pikaday@noreply.github.com>
Cc: eLIANT-TechnologyServices <pkelly@eliantservices.com>; Mention <mention@noreply.github.com>
Subject: Re: [Pikaday/Pikaday] Attach to multiple inputs? (#2)
lmao. Philip, since this is my company account i can't flame you.
but
$('input.datep').pikaday({ firstDay: 1 });
$('input.datep') is usage of the jQuery library and returns a collection of elements.
.pikaday( then calls the plugin "pikaday" for each of those elements and { firstDay: 1 } are the parameters for pikaday
have a nice day.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQAPVFQFATQP4UE2WMMNQXTSCIMKFANCNFSM4ABRSU6A> .
…--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
|
jquery is a library written in javascript you add the jquery source to your html site and then can use jquery functions within javascript code |
How do I attach Pikaday to multiple inputs?
E.g. a typical jQuery approach would look something like this:
The text was updated successfully, but these errors were encountered: